I want 3 sheets with 2 tables each in test.xls. Can anyone help in modifying the below code
ods excel file="/reports/test.xlsx" options(sheet_name="Sh1" sheet_interval="none");
proc print data=sashelp.class(obs=3) noobs;
run;
proc print data=sashelp.shoes(obs=3) noobs;
run;
ods excel options(sheet_name="Sh2" sheet_interval="table");
proc print data=sashelp.cars (obs=5)noobs;
run;
proc print data=sashelp.shoes(obs=5) noobs;
run;
ods excel options(sheet_name="Sh3" sheet_interval="table");
proc print data=sashelp.cars (obs=1)noobs;
run;
proc print data=sashelp.shoes(obs=1) noobs;
run;
ods excel close;
Try SHEET_INTERVAL = "NOW" to start a new sheet.
This was broken in earlier versions of ODS EXCEL, I believe 9.4M5+ is where this would work correctly. If you're on an earlier version there are workarounds though.
ods excel file="/reports/test.xlsx" options(sheet_name="Sh1" sheet_interval="none");
proc print data=sashelp.class(obs=3) noobs;
run;
proc print data=sashelp.shoes(obs=3) noobs;
run;
ods excel options(sheet_name="Sh2" sheet_interval="table");
proc print data=sashelp.cars (obs=5)noobs;
run;
proc print data=sashelp.shoes(obs=5) noobs;
run;
ods excel options(sheet_name="Sh3" sheet_interval="table");
proc print data=sashelp.cars (obs=1)noobs;
run;
proc print data=sashelp.shoes(obs=1) noobs;
run;
ods excel close;
Check your version with the following code and check the log.
proc product_status;run;
@ss171 wrote:
I want 3 sheets with 2 tables each in test.xls. Can anyone help in modifying the below code
ods excel file="/reports/test.xlsx" options(sheet_name="Sh1" sheet_interval="none"); proc print data=sashelp.class(obs=3) noobs; run; proc print data=sashelp.shoes(obs=3) noobs; run; ods excel options(sheet_name="Sh2" sheet_interval="table"); proc print data=sashelp.cars (obs=5)noobs; run; proc print data=sashelp.shoes(obs=5) noobs; run; ods excel options(sheet_name="Sh3" sheet_interval="table"); proc print data=sashelp.cars (obs=1)noobs; run; proc print data=sashelp.shoes(obs=1) noobs; run; ods excel close;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.