Hello,
It is not clear which format is your snapdate variable so you will probably have to adapt a little to suit your needs.
data test;
infile cards;
informat snapdate monyy.;
Input snapdate Account $ Amount;
cards;
Dec16 A 10
Jan17 A 20
Feb17 A 30
Mar17 A 40
Apr17 A 50
May17 A 60
Jun17 A 70
Jul17 A 80
Aug17 A 90
Sep17 A 100
Oct17 A 110
Nov17 A 120
Dec17 A 130
;
run;
%macro split;
data _NULL_;
length lst_data $200.;
lst_data='';
do i=0 to 11;
dt=intnx('month','01Dec17'd,-i);
lst_data=cat(strip(lst_data),' ','test_',year(dt),put(month(dt),z2.));
end;
call symputx("lst_data",lst_data);
run;
data &lst_data.;
set test;
%do i=1 %to %sysfunc(countw(&lst_data.));
if snapdate=intnx('month','01Dec17'd,-&i.+1) then output %scan(&lst_data.,&i.,%str( ));
%end;
run;
%mend;
%split;
proc print data=test_201701;
format snapdate monyy.;
run;
... View more