<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ODS Excel Multiple Sheets in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230183#M14511</link>
    <description>&lt;P&gt;Hi:&lt;BR /&gt;&amp;nbsp; SAS Kiwi is correct, with a FILE= option, the file is completely overwritten each time. Generally, you want to do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods excel file='something.xlsx';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro call for first sheet;&lt;BR /&gt;%macro callfor second sheet;&lt;/P&gt;
&lt;P&gt;ods excel close;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then INSIDE the macro definition if you want to provide a sheet name or other suboptions, your macro does NOT provide file=, it only provides the sheet name and suboptions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro examp;&lt;BR /&gt;&amp;nbsp; ods excel options(sheet_name="&amp;amp;macvar" ...other options);&lt;BR /&gt;&amp;nbsp; proc whatever data=work.somefile;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; run;&lt;BR /&gt;%mend examp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WITHOUT any FILE= or CLOSE inside the macro code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ODS has ALWAYS worked this way. EVERY FILE= overwrites an existing file of the same name. An ODS FILE= will NOT add to an existing file, unless you are 1) using HTML and 2) using a FILEREF with the MOD option. An ODS TAGSETS.EXCELXP or ODS EXCEL FILE= will NOT add to an Excel workbook.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;</description>
    <pubDate>Thu, 15 Oct 2015 21:57:54 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2015-10-15T21:57:54Z</dc:date>
    <item>
      <title>ODS Excel Multiple Sheets</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230131#M14502</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having trouble getting ODS Excel to output a .xlsx file in the format I'd like.&amp;nbsp; I have the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO &lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;print (cat=, colcat=, subcat=, blank=);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ods excel file= &lt;FONT color="#800080" size="3" face="Courier New"&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;"&amp;amp;outpt.&amp;amp;filedate Target All Bed Day Variance.xlsx"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;ods excel options(sheet_name= &lt;FONT color="#800080" size="3" face="Courier New"&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;"&amp;amp;subcat &amp;amp;colcat"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt; sheet_interval=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;'none'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt; absolute_column_width = &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;&lt;FONT color="#800080" size="3" face="Courier New"&gt;"8,9,7,7,6,6,9,7,7,6,6,9,7,7,6,6,9,7,7,6"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/* lots of unshown, not relevant to question code here */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;ods excel close;&lt;/P&gt;&lt;P&gt;%MEND&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;print;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;print&lt;/I&gt;&lt;/STRONG&gt; (cat=PCSA, colcat=PCSA, subcat=NORTH, blank=mob);&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;print&lt;/I&gt;&lt;/STRONG&gt; (cat=PCSA, colcat=PCSA, subcat=EAST, blank=mob);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;Because I'm restating the file location within the macro, the file is overwritten each time I call the macro, and instead of getting a .xlsx file with two sheets (one for each time the macro is called), I only get the sheet created for the last time the macro is called.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;If I remove the file path outside (above)&amp;nbsp;the macro, I get the error:&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Insufficient authorization to access /apps/sas/sas94/config/Lev1/NWWest/sasexcl.xlsx.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;The macro then doesn't know where to look for the file.&amp;nbsp; Any suggestions?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;&lt;FONT size="3" face="Courier New"&gt;Thank you!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2015 18:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230131#M14502</guid>
      <dc:creator>tegant</dc:creator>
      <dc:date>2015-10-15T18:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel Multiple Sheets</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230132#M14503</link>
      <description>&lt;P&gt;With ODS you cannot add to an existing Excel workbook, you can only create one from scratch each time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to&amp;nbsp;&lt;SPAN&gt;add to an existing Excel workbook you need to look an other export options like PROC EXPORT or the EXCEL LIBNAME engine.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2015 18:38:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230132#M14503</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2015-10-15T18:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel Multiple Sheets</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230136#M14505</link>
      <description>&lt;P&gt;Hi SASkiwi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't believe what you said is the case.&amp;nbsp; I'm remediating code from:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods tagsets.excelxp&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods excel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code works in ods tagsets.excelxp when the filename above the macro.&amp;nbsp; It produces a .xls workbook with multiple tabs.&amp;nbsp; I need a .xlsx workbook, so I need to use 'ods excel'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2015 18:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230136#M14505</guid>
      <dc:creator>tegant</dc:creator>
      <dc:date>2015-10-15T18:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel Multiple Sheets</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230183#M14511</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;&amp;nbsp; SAS Kiwi is correct, with a FILE= option, the file is completely overwritten each time. Generally, you want to do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods excel file='something.xlsx';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro call for first sheet;&lt;BR /&gt;%macro callfor second sheet;&lt;/P&gt;
&lt;P&gt;ods excel close;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then INSIDE the macro definition if you want to provide a sheet name or other suboptions, your macro does NOT provide file=, it only provides the sheet name and suboptions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro examp;&lt;BR /&gt;&amp;nbsp; ods excel options(sheet_name="&amp;amp;macvar" ...other options);&lt;BR /&gt;&amp;nbsp; proc whatever data=work.somefile;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; run;&lt;BR /&gt;%mend examp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WITHOUT any FILE= or CLOSE inside the macro code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ODS has ALWAYS worked this way. EVERY FILE= overwrites an existing file of the same name. An ODS FILE= will NOT add to an existing file, unless you are 1) using HTML and 2) using a FILEREF with the MOD option. An ODS TAGSETS.EXCELXP or ODS EXCEL FILE= will NOT add to an Excel workbook.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2015 21:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230183#M14511</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2015-10-15T21:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel Multiple Sheets</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230200#M14514</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Thanks Cynthia...while what you wrote works for me using 'ods tagsets.excelxp' to create a multisheet .xls file, it does not work for me when I use 'ods excel' to create a multisheet .xlsx file.&amp;nbsp; I get this error:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Insufficient authorization to access /apps/sas/sas94/config/Lev1/NWWest/sasexcl.xlsx.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not finding the original file and looking somewhere else where the file doesn't exist and where I don't have access to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2015 23:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230200#M14514</guid>
      <dc:creator>tegant</dc:creator>
      <dc:date>2015-10-15T23:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: ODS Excel Multiple Sheets</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230208#M14516</link>
      <description>Hi: Unfortunately, this is an instance where someone has to look at ALL your code, including the long parts and the macro code. It seems like you have an access problem or an issue with your macro variable or you have a stray CLOSE someplace in your code that did not get deleted.&lt;BR /&gt;&lt;BR /&gt;This is really something that is best worked on with Tech Support. They can replicate your version of SAS and experiment with your code to see if they experience the same issue that you report.&lt;BR /&gt; &lt;BR /&gt;cynthia</description>
      <pubDate>Fri, 16 Oct 2015 02:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Excel-Multiple-Sheets/m-p/230208#M14516</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2015-10-16T02:40:28Z</dc:date>
    </item>
  </channel>
</rss>

