Hi there, I want to create a backbone table using Macro at a starting YYYY-MM that equals (Variable_NAME_TIME) to 1 and then as time moves forward the 'Variable_NAME_TIME' will increase by a increment of 1 until previous month. In this case Sept 2022.
for example:
Yr_mon Variable_NAME_TIME
2021-04 1
2021-05 2
2021-06 3
2021-07 4
2021-08 5
2021-09 6
I was able to come up with a macro loop to get YYYY-Mon but not how to get Variable_NAME_TIME. Any suggestions or advice would be very appreciated!
*SET MACRO BEGIN DATE;
%let begin_date = '2021-04';
%put &begin_date;
* SET MACRO END DATE IN YYYY-MM;
%let Prev_Month_short = %sysfunc(intnx(month,%sysfunc(date()),-1),YYMMD.);
%put &Prev_Month_short;
* SET MACRO CURRENT DATE IN YYYY-MM;
%let Cur_Month = %sysfunc(today(),YYMMD.);
%put &Cur_Month;
%macro date_loop(start,end);
%let start=%sysfunc(inputn(&start,anydtdte9.));
%let end=%sysfunc(inputn(&end,anydtdte9.));
%let dif=%sysfunc(intck(month,&start,&end));
%do i=0 %to &dif;
%let date=%sysfunc(intnx(month,&start,&i,b),YYMMD.);
%put &date;
%end;
%mend date_loop;
%date_loop(&begin_date , &Prev_Month_short)
... View more