complete macrotized code, based on the run date you mention or today's date it will pick the dates as you mentioned and create the data. see if this is helpful.
data _null_;
call symputx('run_dt',compress(put(intnx('day',today(),0),yymmn6.)));/*Start date--use %let run_dt=value if want other dates*/
call symputx('dtp6mon1',compress(put(intnx('month',today(),-6),yymmn6.))); /*6months previous date to current date**/
call symputx('dtp6mon2',compress(put(intnx('month',today(),-12),yymmn6.)));/*6months previous date to dtp6mon1...**/
call symputx('dtp6mon3',compress(put(intnx('month',today(),-18),yymmn6.)));
call symputx('dtp6mon4',compress(put(intnx('month',today(),-24),yymmn6.)));
call symputx('dtp6mon5',compress(put(intnx('month',today(),-30),yymmn6.)));
call symputx('dtp6mon6',compress(put(intnx('month',today(),-36),yymmn6.)));
run;
%put run_dt=&run_dt.;
%put dtp6mon1=&dtp6mon1.;
%put dtp6mon2=&dtp6mon2.;
%put dtp6mon3=&dtp6mon3.;
%put dtp6mon4=&dtp6mon4.;
%put dtp6mon5=&dtp6mon5.;
%put dtp6mon6=&dtp6mon6.;
data new;
set s_&dtp6mon6. s_&dtp6mon5. s_&dtp6mon4. s_&dtp6mon3. s_&dtp6mon2. s_&dtp6mon1.;
run;
Thanks,
Vish
... View more