Help using Base SAS procedures

ODS tagset xml help

Posts: 59

ODS tagset xml help

data rpt1


set main1;

if id=1 then output r1

else output r2;


ods listing close;

%macro findit(ds,name);

ods tagsets.ExcelXP




I now want to do an xml output. using ods tagset.excelxp.  I want r1 to be in a tab and r2 to be in another tab.  When I have experimented, all the data eds up going into the r2 or seconone.  Is it best to do this with or without a global macro??

Super User
Posts: 17,819

Re: ODS tagset xml help

You can only create an ods excelxp file in one run.

If you close the file you can't reopen it to append to it. You haven't shown the full macro so I can't say where the problem is but you could just display your data using a by group and using the option sheet_interval=bygroup instead. 

There's some good examples of that on this forum if you google a bit. Look for posts by Cynthia Zender.

Posts: 8,743

Re: ODS tagset xml help


  As Reeza suggests, you cannot append to a TAGSETS.EXCELXP XML file once you have closed it. My rule of thumb when working with macro programs is to start with a working SAS program, so you know what kind of code your macro program has to generate For example, if you had tried to create a 2-tab workbook, you could have done it in one ODS "sandwich" with one procedure step creating output for the first tab, and the second procedure step creating output for the second tab (taking all the defaults).

Generally, this means code similar to the code shown below, which creates a multi-sheet workbook. Once you get code like this working for your report, then, and only then, should you look to "macro-ize" your code. It doesn't help to macro-ize non-working code, that is nearly impossible to debug.


ods tagsets.excelxp file='c:\temp\multsheet.xml'

    options(doc='Help' sheet_name='Starts with J')



proc  print data=sashelp.class noobs;

  where substr(name,1,1) = 'J';



ods tagsets.excelxp options(sheet_name='Starts A, B, C');


proc print data=sashelp.class noobs;

  where substr(name,1,1) in ('A','B','C');


ods tagsets.excelxp close;

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation