%macro example
%let begdate = ’01Nov2004’d;
%let enddate = ’30Nov2004’d;
proc sort data=test out=test2;
where date between &begdate and &enddate;
by date;
run;
%mend example;
此代码给出了错误:ERROR: Syntax error while parsing WHERE clause.
但是,当我简单地用相应的值替换& begdate和& enddate时,它就可以工作。
答案 0 :(得分:1)
我通常这样经营:
%macro example
%let begdate = 01Nov2004;
%let enddate = 30Nov2004;
proc sort data=test out=test2;
where date between "&begdate"d and "&enddate"d;
by date;
run;
%mend example;
我只是删除了日期格式的任何假设,并将代码中的宏变量称为字符串。希望这会有所帮助!!