BookmarkSubscribeRSS Feed
ss171
Calcite | Level 5

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;
2 REPLIES 2
Reeza
Super User

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;

 

ss171
Calcite | Level 5
thank you , this works

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 409 views
  • 0 likes
  • 2 in conversation