<?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 Multiple tables export to one excel spreadsheet in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/393573#M19251</link>
    <description>&lt;P&gt;Hello SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to export multiple data sets to single excel spreadsheet by using ods excelxp SAS 9.3. &amp;nbsp;When I ran my code, SAS output&amp;nbsp;my each table to one spreadsheet. I need the second loop tables on one sheet. Any helps are appreciated. Here is my code:&lt;/P&gt;&lt;P&gt;data varlist;&lt;BR /&gt;input name$ 20. ;&lt;BR /&gt;datalines;&lt;BR /&gt;Survey_1&lt;BR /&gt;Survey_2&lt;BR /&gt;Survey_3&lt;BR /&gt;Survey_4&lt;BR /&gt;Survey_5&lt;BR /&gt;Survey_6&lt;BR /&gt;Survey_7&lt;BR /&gt;Survey_8&lt;BR /&gt;Survey_9&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select name into :var1 - :var9&lt;BR /&gt;from varlist;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data vlist;&lt;BR /&gt;input name$ 15. ;&lt;BR /&gt;datalines;&lt;BR /&gt;&amp;nbsp;Life&lt;BR /&gt;Health&lt;BR /&gt;Property&lt;BR /&gt;Casualty&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select name into :v1 - :v4&lt;BR /&gt;from vlist;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ODS noresults;&lt;BR /&gt;ODS listing close; /*Turn off the standard line printer destination*/&lt;BR /&gt;ods tagsets.ExcelXP path="&amp;amp;dir."&lt;BR /&gt;file="Testreport_2017.xml"&lt;BR /&gt;style=seaside /*Styles to control appearance of output*/;&lt;BR /&gt;%macro exceloutput;&lt;BR /&gt;%do i=1 %to 4;&lt;BR /&gt;ods tagsets.ExcelXP&lt;BR /&gt;options ( sheet_name= "&amp;amp;&amp;amp;v&amp;amp;i." autofit_height= 'yes' Sheet_interval="none" absolute_column_width= '8,8,8,8,8,8,8,8');&lt;BR /&gt;title j=l "All ";&lt;BR /&gt;options missing=" ";&lt;BR /&gt;proc report data=allpass(where=(examtitle="&amp;amp;&amp;amp;v&amp;amp;i.")) NOWD;&lt;BR /&gt;Column group total ("Overall" npass passpct) ("General" gpass gpasspct) ("State" spass spasspct);&lt;BR /&gt;define group /Center display "Group";&lt;BR /&gt;define total / center display "Total";&lt;BR /&gt;define npass / center display "N" ;&lt;BR /&gt;define passpct /center display "PCT";&lt;BR /&gt;define gpass /center display "N";&lt;BR /&gt;define gpasspct /center display "PCT" ;&lt;BR /&gt;define spass /center display "N";&lt;BR /&gt;define spasspct /center display "PCT" ;&lt;BR /&gt;compute group;&lt;BR /&gt;count+1;&lt;BR /&gt;if (mod(count,2)) then do;&lt;BR /&gt;call define(_row_,"style","style=[background=CXECEDEC]");&lt;BR /&gt;end;&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;BR /&gt;%do j=1 %to 9;&lt;BR /&gt;ods tagsets.ExcelXP&lt;BR /&gt;options ( sheet_name= "&amp;amp;&amp;amp;v&amp;amp;i." autofit_height= 'yes' Sheet_interval="none" absolute_column_width= '8,8,8,8,8,8,8,8' );&lt;BR /&gt;options missing=" ";&lt;BR /&gt;title "&amp;amp;&amp;amp;var&amp;amp;j.";&lt;BR /&gt;proc report data=surveypass&amp;amp;j.(where=(examtitle="&amp;amp;&amp;amp;v&amp;amp;i.")) NOWD;&lt;BR /&gt;Column &amp;amp;&amp;amp;var&amp;amp;j. total ("Overall" npass passpct) ("General" gpass gpasspct) ("State" spass spasspct);&lt;BR /&gt;define &amp;amp;&amp;amp;var&amp;amp;j. /Center display "Group";&lt;BR /&gt;define total / center display "Total";&lt;BR /&gt;define npass / center display "N" ;&lt;BR /&gt;define passpct /center display "PCT" style(column)={tagattr="format:###0.00%"};&lt;BR /&gt;define gpass /center display "N";&lt;BR /&gt;define gpasspct /center display "PCT" style(column)={tagattr="format:###0.00%"};&lt;BR /&gt;define spass /center display "N" ;&lt;BR /&gt;define spasspct /center display "PCT" style(column)={tagattr="format:###0.00%"};;&lt;BR /&gt;compute total;&lt;BR /&gt;count+1;&lt;BR /&gt;if (mod(count,2)) then do;&lt;BR /&gt;call define(_row_,"style","style=[background=CXECEDEC]");&lt;BR /&gt;end;&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;ods tagsets.excelxp options(sheet_interval="table" sheet_name=&amp;amp;&amp;amp;v&amp;amp;i. );&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%exceloutput;&lt;BR /&gt;ods tagsets.excelxp close; /* Close and release the xml file so it can be opened with Excel*/&lt;BR /&gt;ODS listing;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Sep 2017 14:22:55 GMT</pubDate>
    <dc:creator>daisy6</dc:creator>
    <dc:date>2017-09-06T14:22:55Z</dc:date>
    <item>
      <title>Multiple tables export to one excel spreadsheet</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/393573#M19251</link>
      <description>&lt;P&gt;Hello SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to export multiple data sets to single excel spreadsheet by using ods excelxp SAS 9.3. &amp;nbsp;When I ran my code, SAS output&amp;nbsp;my each table to one spreadsheet. I need the second loop tables on one sheet. Any helps are appreciated. Here is my code:&lt;/P&gt;&lt;P&gt;data varlist;&lt;BR /&gt;input name$ 20. ;&lt;BR /&gt;datalines;&lt;BR /&gt;Survey_1&lt;BR /&gt;Survey_2&lt;BR /&gt;Survey_3&lt;BR /&gt;Survey_4&lt;BR /&gt;Survey_5&lt;BR /&gt;Survey_6&lt;BR /&gt;Survey_7&lt;BR /&gt;Survey_8&lt;BR /&gt;Survey_9&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select name into :var1 - :var9&lt;BR /&gt;from varlist;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data vlist;&lt;BR /&gt;input name$ 15. ;&lt;BR /&gt;datalines;&lt;BR /&gt;&amp;nbsp;Life&lt;BR /&gt;Health&lt;BR /&gt;Property&lt;BR /&gt;Casualty&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select name into :v1 - :v4&lt;BR /&gt;from vlist;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ODS noresults;&lt;BR /&gt;ODS listing close; /*Turn off the standard line printer destination*/&lt;BR /&gt;ods tagsets.ExcelXP path="&amp;amp;dir."&lt;BR /&gt;file="Testreport_2017.xml"&lt;BR /&gt;style=seaside /*Styles to control appearance of output*/;&lt;BR /&gt;%macro exceloutput;&lt;BR /&gt;%do i=1 %to 4;&lt;BR /&gt;ods tagsets.ExcelXP&lt;BR /&gt;options ( sheet_name= "&amp;amp;&amp;amp;v&amp;amp;i." autofit_height= 'yes' Sheet_interval="none" absolute_column_width= '8,8,8,8,8,8,8,8');&lt;BR /&gt;title j=l "All ";&lt;BR /&gt;options missing=" ";&lt;BR /&gt;proc report data=allpass(where=(examtitle="&amp;amp;&amp;amp;v&amp;amp;i.")) NOWD;&lt;BR /&gt;Column group total ("Overall" npass passpct) ("General" gpass gpasspct) ("State" spass spasspct);&lt;BR /&gt;define group /Center display "Group";&lt;BR /&gt;define total / center display "Total";&lt;BR /&gt;define npass / center display "N" ;&lt;BR /&gt;define passpct /center display "PCT";&lt;BR /&gt;define gpass /center display "N";&lt;BR /&gt;define gpasspct /center display "PCT" ;&lt;BR /&gt;define spass /center display "N";&lt;BR /&gt;define spasspct /center display "PCT" ;&lt;BR /&gt;compute group;&lt;BR /&gt;count+1;&lt;BR /&gt;if (mod(count,2)) then do;&lt;BR /&gt;call define(_row_,"style","style=[background=CXECEDEC]");&lt;BR /&gt;end;&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;BR /&gt;%do j=1 %to 9;&lt;BR /&gt;ods tagsets.ExcelXP&lt;BR /&gt;options ( sheet_name= "&amp;amp;&amp;amp;v&amp;amp;i." autofit_height= 'yes' Sheet_interval="none" absolute_column_width= '8,8,8,8,8,8,8,8' );&lt;BR /&gt;options missing=" ";&lt;BR /&gt;title "&amp;amp;&amp;amp;var&amp;amp;j.";&lt;BR /&gt;proc report data=surveypass&amp;amp;j.(where=(examtitle="&amp;amp;&amp;amp;v&amp;amp;i.")) NOWD;&lt;BR /&gt;Column &amp;amp;&amp;amp;var&amp;amp;j. total ("Overall" npass passpct) ("General" gpass gpasspct) ("State" spass spasspct);&lt;BR /&gt;define &amp;amp;&amp;amp;var&amp;amp;j. /Center display "Group";&lt;BR /&gt;define total / center display "Total";&lt;BR /&gt;define npass / center display "N" ;&lt;BR /&gt;define passpct /center display "PCT" style(column)={tagattr="format:###0.00%"};&lt;BR /&gt;define gpass /center display "N";&lt;BR /&gt;define gpasspct /center display "PCT" style(column)={tagattr="format:###0.00%"};&lt;BR /&gt;define spass /center display "N" ;&lt;BR /&gt;define spasspct /center display "PCT" style(column)={tagattr="format:###0.00%"};;&lt;BR /&gt;compute total;&lt;BR /&gt;count+1;&lt;BR /&gt;if (mod(count,2)) then do;&lt;BR /&gt;call define(_row_,"style","style=[background=CXECEDEC]");&lt;BR /&gt;end;&lt;BR /&gt;endcomp;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;ods tagsets.excelxp options(sheet_interval="table" sheet_name=&amp;amp;&amp;amp;v&amp;amp;i. );&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%exceloutput;&lt;BR /&gt;ods tagsets.excelxp close; /* Close and release the xml file so it can be opened with Excel*/&lt;BR /&gt;ODS listing;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 14:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/393573#M19251</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-09-06T14:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple tables export to one excel spreadsheet</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/394106#M19278</link>
      <description>&lt;P&gt;Simplify your code until it works, and then add complexity until it breaks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a starting point, this works fine:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
ods tagsets.ExcelXP path="%sysfunc(pathname(work))"  file="Testreport_2017.xml";

ods tagsets.ExcelXP options ( sheet_name= "F" );

proc print data=SASHELP.CLASS(where=(SEX='F')) ;run;

ods tagsets.ExcelXP options ( sheet_name= "M" );
                                                                         
proc print data=SASHELP.CLASS(where=(SEX='M')) ;run;

ods tagsets.ExcelXP close; 

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 03:01:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/394106#M19278</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-09-08T03:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple tables export to one excel spreadsheet</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/394321#M19288</link>
      <description>&lt;P&gt;You can just simply use libname to refer excel file as a library. Then do multiple DATA step to different excel spreadsheet.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myxls "\\path\filename.xls"; 

DATA myxls.sheetname1;
 SET sasdataset1;
 DATA myxls.sheetname2;
 SET sasdataset2;
 RUN;

proc datasets lib=myxls; quit;
 
libname myxls CLEAR;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Sep 2017 19:04:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/394321#M19288</guid>
      <dc:creator>MINX</dc:creator>
      <dc:date>2017-09-08T19:04:01Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple tables export to one excel spreadsheet</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/394331#M19289</link>
      <description>&lt;P&gt;Thanks for help! I will try to simplify the code and run it.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 19:44:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/394331#M19289</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-09-08T19:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple tables export to one excel spreadsheet</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/394344#M19290</link>
      <description>&lt;P&gt;Do you want to output multiple tables into a single sheet as your title implies?&lt;/P&gt;
&lt;P&gt;Or do you want multiple sheets in the same workbook as it looks like the code is trying to do?&lt;/P&gt;
&lt;P&gt;If the latter then can't you just tell ODS to do that automatically by adding a BY statement and setting the SHEET_INTERVAL option?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 20:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/394344#M19290</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-09-08T20:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple tables export to one excel spreadsheet</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/395617#M19346</link>
      <description>&lt;P&gt;Thanks Tom. I like my multiple tables are written on one spreadsheet of excel, not multiple sheets or tabs of excel. My code works for 9.4 version but not for 9.3 version.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 16:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Multiple-tables-export-to-one-excel-spreadsheet/m-p/395617#M19346</guid>
      <dc:creator>daisy6</dc:creator>
      <dc:date>2017-09-13T16:33:34Z</dc:date>
    </item>
  </channel>
</rss>

