Thanks Tom, it worked great! This is a very nice solution for my task. I made some slight modifications below. This will save writing 100+ lines of code. %macro increment_months(incrmt1_lag6=,end_month=,incrmt2_tzero=); %local sdate edate offset thismonth ldate thismonth1 ; %let sdate=%sysfunc(inputn(&incrmt2_tzero.01,yymmdd8.)); %let edate=%sysfunc(inputn(&end_month.01,yymmdd8.)); %let ldate=%sysfunc(inputn(&incrmt1_lag6.01,yymmdd8.)); %do offset=0 %to %sysfunc(intck(month,&sdate,&edate)); %let thismonth=%sysfunc(intnx(month,&sdate,&offset)); %let thismonth1=%sysfunc(intnx(month,&ldate,&offset)); %put &=offset &=thismonth %sysfunc(putn(&thismonth,date9.)) %sysfunc(putn(&thismonth,yymmn6.)); %put &=offset &=thismonth1 %sysfunc(putn(&thismonth1,date9.)) %sysfunc(putn(&thismonth1,yymmn6.)); %PULLIT(BY=,WHERE=,CLASS=&SPLITTER, TIMEZERO=%sysfunc(putn(&thismonth,yymmn6.)), START_MONTH=%sysfunc(putn(&thismonth1,yymmn6.)), STOP_MONTH=&EOP); %end; %mend increment_months; %increment_months(incrmt1_lag6=202109,end_month=202205,incrmt2_tzero=202204);
... View more