SAS outputexcel 多sheet
%macro outputexcel(lib=);
data table1;
set sashelp.vcolumn;
where libname=upcase("&lib");
KEEP libname memname;
run;
proc sort data=table1 out=table2 nodupkey;
by memname;
run;
data _null_;
set table2 end=eof;
call symput("varname"||strip(put(_n_,3.)),memname);
if eof then call symput("varsum",_n_);
run;
%put &varname2;
%put &varsum;
%global i;
%let excelname=%sysfunc(today(),yymmddn8.);
data _null_;
%do i=1 %to &varsum;
proc export data=&lib..&&varname&i outfile="Z:\06 DM\DATA\Project\MB-MMX-001\QC\EditChecks\eidtcheck_&excelname" dbms=xlsx replace;
sheet=&&varname&i;
run;
%end;
run;
%mend;
/*%outputexcel(lib=sdtm,excelname=567);*/
data table1;
set sashelp.vcolumn;
where libname=upcase("&lib");
KEEP libname memname;
run;
proc sort data=table1 out=table2 nodupkey;
by memname;
run;
data _null_;
set table2 end=eof;
call symput("varname"||strip(put(_n_,3.)),memname);
if eof then call symput("varsum",_n_);
run;
%put &varname2;
%put &varsum;
%global i;
%let excelname=%sysfunc(today(),yymmddn8.);
data _null_;
%do i=1 %to &varsum;
proc export data=&lib..&&varname&i outfile="Z:\06 DM\DATA\Project\MB-MMX-001\QC\EditChecks\eidtcheck_&excelname" dbms=xlsx replace;
sheet=&&varname&i;
run;
%end;
run;
%mend;
/*%outputexcel(lib=sdtm,excelname=567);*/