Hello, I need some help. I have 8 tables/datasets in SAS that I want to export to Excel using ODS Excel. They all need to go in one excel file with three tabs. Out of these 8 tables, 4 need to go in the 1st tab, two in the 2nd tab and last two need to go in the 3rd tab. I know how to have either all tables in one tab (using sheet_interval='NONE') or have all the tables in a separate tab (using sheet_interval='YES') but I do not know how to accomplish what I need to do.
I appreciate your help.
Thank you
ods excel file='c:\temp\temp.xlsx' options(sheet_name='First Tab' sheet_interval='none');
/*First table*/
proc print data=sashelp.class;run;
/*Second table*/
proc print data=sashelp.class;run;
ods excel options(sheet_name='Second Tab' sheet_interval='proc');
/*Third table*/
proc print data=sashelp.class(obs=4);run;
ods excel options(sheet_interval='none');
/*Fourth table*/
proc print data=sashelp.class(obs=4);run;
ods excel options(sheet_name='Third Tab' sheet_interval='proc');
/*Fifth table*/
proc print data=sashelp.class(obs=8);run;
ods excel options(sheet_interval='none');
/*Sixth table*/
proc print data=sashelp.class(obs=8);run;
ods excel close;
ods excel file='c:\temp\temp.xlsx' options(sheet_name='First Tab' sheet_interval='none');
/*First table*/
proc print data=sashelp.class;run;
/*Second table*/
proc print data=sashelp.class;run;
ods excel options(sheet_name='Second Tab' sheet_interval='proc');
/*Third table*/
proc print data=sashelp.class(obs=4);run;
ods excel options(sheet_interval='none');
/*Fourth table*/
proc print data=sashelp.class(obs=4);run;
ods excel options(sheet_name='Third Tab' sheet_interval='proc');
/*Fifth table*/
proc print data=sashelp.class(obs=8);run;
ods excel options(sheet_interval='none');
/*Sixth table*/
proc print data=sashelp.class(obs=8);run;
ods excel close;
Thank you for your help! It worked beautifully!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.