Reputation:
I am trying to create a macro that will execute other SAS scripts based on a check of the week.
data _null_;
week_num = week(); /*Current week is 31*/
call symput('week_num',week_num);
run;
%macro testmacro(week_num);
%if &week_num. = 31 %then %do;
%put This works;
%end;
%mend testmacro;
%testmacro(%week_num.);
I have used week 31 as an example, since this is the week of posting this question. I keep getting the message: WARNING: Apparent invocation of macro WEEK_NUM not resolved. I do not understand what I am missing to get the macro to be called correctly.
Upvotes: 0
Views: 695
Reputation: 51566
You defined a macro variable named WEEK_NUM, but you are trying to execute a macro named WEEK_NUM instead of referencing the macro variable you created.
Use & to reference a macro variable and % to execute a macro. So in this line TESTMACRO is an actual macro and WEEK_NUM is a macro variable (also called a symbol).
%testmacro(&week_num.);
Upvotes: 0