BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,
How do I generate separate ODS html outputs as different tabs in an excel file.

Example:
-------------
ODS html file = 'C:\abe\dee\xyz\123.xls';
proc print data=something;
run;
ods html close;

ODS html file = 'C:\abe\dee\xyz\789.xls';
proc print data=else;
run;
ods html close;

Now, instead of these ODS statements generating two separate xls files, I want both the outputs in different tabs of the same excel file.

Thanks in advance for your help
- Einnor
1 REPLY 1
Cynthia_sas
Diamond | Level 26
Hi:
This is a good example of when you might consider a change to using the EXCELXP tagset:
[pre]
ODS tagsets.excelxp file = 'C:\temp\multsheet.xls';
proc print data=sashelp.class;
run;

proc print data=sashelp.shoes(obs=5);
run;

proc freq data=sashelp.shoes;
tables region;
run;
ods tagsets.excelxp close;

[/pre]

That because when you use Spreadsheet Markup Language (Microsoft's XML specification for a Workbook defined in XML tags), there is one <Workbook> tag in the XML file and every worksheet is contained within separate <Worksheet> tags. The ODS developers followed the Microsoft specification -- so by default, when you switch to TAGSETS.EXCELXP to create your XML file, every procedure invocation that you have inside the ODS "sandwich" becomes a separate Excel worksheet tab in one workbook. ODS puts in the right combination of <Workbook> and <Worksheet> tags

On the other hand, by Microsoft design/spec., when you create an HTML file, every HTML file becomes a separate Workbook -- unless you do something extra to link the HTML files together and store them in the same physical directory and have a separate external XML file that describes the files that get linked together. This is a more complicated method to get multiple tabs, but it is what you used to have to do in SAS 8 before TAGSETS.EXCELXP was available. That method is described here:
http://support.sas.com/rnd/base/topics/excel/multisheet_excel_post.ppt

For more information on ODS MARKUP and TAGSETS.EXCELXP, refer to ODS MARKUP resources site:
http://support.sas.com/rnd/base/topics/odsmarkup/

and this paper has a good introduction to the topic:
http://support.sas.com/rnd/base/topics/odsmarkup/Paper_227-2007_ODS_Office.pdf

cynthia

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

Register now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1027 views
  • 0 likes
  • 2 in conversation