*****************************************宏1**********************************************
%macro sets(ins,cate=sales,outf=test);
proc sort data=&ins out=a1 nodupkey;
by &cate;
run;
data _null_;
if 0 then set a1 nobs=a;
call symput('obs',a);
run;
%do i=1 %to &obs;
data _null_;
set a1;
if _n_ eq &i;
call symput('cate'||left(&i),&cate );
run;
data d&i;
set &ins;
if &cate eq "&&cate&i";
run;
%excel(d&i,&outf,&&cate&i)
%end;
%mend;
***************************************宏2**************************************
宏1调用了宏2
%macro excel(in,filename,label);
proc export data=&in outfile="E:\数据结果\excel_o\&filename..xls"
dbms=excelcs label replace;
sheet="&label";
run;
%mend;