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
SAS Super FREQ
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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1 reply
  • 571 views
  • 0 likes
  • 2 in conversation