3qsir 发表于 2014-3-14 16:50
OK! Thank for your help.
You use the simply pro sql through %m(201103)
you can create a macro to repeat this code
%macro a;
%do i=199101 %to 201103;
%macro m(v);
%let y=%substr(&v.,1,4);
%let m=%substr(&v.,5,2);
%do i=1 %to 24;
%let mf=%sysfunc(putn(%eval(&m.+&i.-1),z2.));
%if &mf.>24 %then %do;
%let mf=%sysfunc(putn(%eval(&mf.-24),z2.));
%let yf=%eval(&y.+2);
%end;
%else %if &mf.>12 %then %do;
%let mf=%sysfunc(putn(%eval(&mf.-12),z2.));
%let yf=%eval(&y.+1);
%end;
%else %let yf=&y.;
,t1.%sysfunc(cats(%bquote('&yf.&mf.'), n)) as K&i.
%end;
%mend m;
/*%m(201103);*/
proc sql noprint;
create table test&i as
select t1.IND
%m(&i)
from work.monthly t1
;
quit;
%end;
%mend a;
%a;