Reputation: 17428
I currently using:
data _null_;
do i = 1 to 5;
temp = -10 * i;
%let minimum_date = %sysfunc(intnx(day,%sysfunc(today()),temp),date9.);
PUT temp;
end;
run;
This gives me an error:
ERROR: Argument 3 to function INTNX referenced by the %SYSFUNC or %QSYSFUNC macro function is not a number.
Any ideas how to fix this please?
PS:
Ultimate aim expressed as pseudo-ish code:
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;
Upvotes: 0
Views: 78
Reputation: 51621
You asked SAS to evaluate the string TEMP as if it was a number. You should just remove the macro code and use normal code.
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;
Or you could write a macro so that you could use a %DO loop.
%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;
Upvotes: 3