我目前正在使用:
data _null_;
do i = 1 to 5;
temp = -10 * i;
%let minimum_date = %sysfunc(intnx(day,%sysfunc(today()),temp),date9.);
PUT temp;
end;
run;
这给了我一个错误:
ERROR: Argument 3 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.
任何想法如何解决这个问题?
PS:
终极目标表示为伪代码:
data _null_;
do i = 1 to 5;
* set minimum_date to today - i*-10;
minimum_date = intnx('day',today(),i*-10);
* assign minimum_date to macro variable min_date;
call symput(min_date,minimum_date);
* invoke programs that use macro variable;
%include '/Bla/ChildProgram1.sas';
%include '/Bla/ChildProgram2.sas';
end;
run;
答案 0 :(得分:3)
您要求SAS将字符串TEMP评估为数字。您应该删除宏代码并使用普通代码。
data _null_;
do i = 1 to 5;
minimum_date = intnx('day',today(),i*-10);
format mininum_date date9.;
put i= minimum_date=;
call execute(cats('%nrstr(%let) minimum_date=',put(minimum_date,date9),';'));
call execute("%include '/Bla/ChildProgram1.sas';");
call execute("%include '/Bla/ChildProgram2.sas';");
end;
run;
或者您可以编写一个宏,以便可以使用%DO循环。
%macro runall ;
%let start=%sysfunc(today());
%do i=1 %to 5;
%let minimum_date=%sysfunc(intnx(day,&start,-10*&i),date9);
%include '/Bla/ChildProgram1.sas';
%include '/Bla/ChildProgram2.sas';
%end;
%mend runall;
%runall;