0
votes

I'm trying to write a macro to replace some current code. The current code is like this:

data _null_;
 call symput('as_of_date_nbr1', put(intnx('month', today(),-1, 'E'), yymmddn.));
run;
%put &as_of_date_nbr1 yields 20210831

There is a data_null for each of 30 months. That variable is then used in a data step where statement

where date = &as_of_date_nbr1

I want to write a macro where the variable as_of_date_nbr would take a macro variable from 1-30 and the intnx function would also take a macro variable from 1-30 So something like this if possible in a loop

data _null_;
call symput('as_of_date_nbr.&macvar, put(intnx('month,today(),-&macvar, 'E'), yyyymmddn.))

So far I'm not having any luck, any ideas would be appreciated.