The SAS Output Delivery System and reporting techniques

Generating excel tabs

Not applicable
Posts: 0

Generating excel tabs

How do I generate separate ODS html outputs as different tabs in an excel file.

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

ODS html file = 'C:\abe\dee\xyz\789.xls';
proc print data=else;
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
Posts: 9,366

Re: Generating excel tabs

Posted in reply to deleted_user
This is a good example of when you might consider a change to using the EXCELXP tagset:
ODS tagsets.excelxp file = 'C:\temp\multsheet.xls';
proc print data=sashelp.class;

proc print;

proc freq;
tables region;
ods tagsets.excelxp close;


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:

For more information on ODS MARKUP and TAGSETS.EXCELXP, refer to ODS MARKUP resources site:

and this paper has a good introduction to the topic:

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation