data test;
input stkcd $ time:yymmdd10. ri;
format time yymmdd10.;
datalines;
a1364654 2015-04-02 0.02
a1364652 2015-04-02 0.02
a1364654 2015-04-02 0.02
a1364653 2015-04-02 0.02
a1364654 2015-04-02 0.02
a1364652 2015-04-02 0.02
a1364654 2015-04-02 0.02
;
run;
/*将股票代码汇总*/
proc sql;
create table one as select distinct stkcd
from test;
/*group by stkcd;*/
quit;
/*共有多少个股票代码,设置宏*/
data _null_ ;
set one end=final;
call symput(compress('ST'||left(_n_)),stkcd);
if final then call symput('N',_n_);
run;
%macro ttt();
%do i=1 %to &N.;
data &&ST&i.;
set test;
if stkcd="&&ST&i." then output &&ST&i.;
run;
%end;
%mend;
/*调用宏语句*/
%ttt();