Reputation: 35
I have a macro which looks like this:
%macro mac_name (st, en=);
%do j=1 %to &en.;
%let k=%eval(&j.+1);
proc freq data=data_name;
tables status&j. * status&k. / nocol norow nopercent missing;
run;
%end;
%mend;
%mac_name (st=1, en=%sysfunc(week(%sysfunc(today()), u)));
The output produces multiple proc freq tables with the same title. I need this output put into a excel spreadsheet. Ideally all proc freqs in one sheet, one above the other or separate sheets.
Is this possible?
Thanks in advance!!!
Upvotes: 1
Views: 13881
Reputation: 63424
The easiest way to do this is to use ODS EXCEL
, if you have SAS 9.4.
ods excel file="yourfilename.xlsx";
proc freq data=sashelp.class;
tables age;
run;
proc freq data=sashelp.class;
tables sex;
run;
ods excel close;
You have options for whether they're all on one sheet or separate sheets. You can use ODS TAGSETS.EXCELXP
if you have an earlier version of SAS, though they're less "true excel" files. You can also make CSV files or various other things with ODS
.
In your case you'd put the opening ODS EXCEL
line before the first call of the macro (doesn't have to precede the definition of the macro) and then the ODS EXCEL CLOSE
line after the last call.
Upvotes: 2