<?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: how to split excel export into separate sheets in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-split-excel-export-into-separate-sheets/m-p/225211#M5401</link>
    <description>If you have a large number of values for "Area" and "Chart_Field_1", you can use a macro to loop through the possible values and output a corresponding Excel workbook for each value of "Area" containing separate spreadsheets for each value of "Chart_Field_1".&lt;BR /&gt;&lt;BR /&gt;To give you some ideas, look at this post: &lt;A href="https://communities.sas.com/t5/SAS-Procedures/Split-SAS-Output-into-multiple-Sheets/td-p/18996" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Split-SAS-Output-into-multiple-Sheets/td-p/18996&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If the number of variables is small, you could hard-code them.</description>
    <pubDate>Fri, 11 Sep 2015 18:37:33 GMT</pubDate>
    <dc:creator>Fugue</dc:creator>
    <dc:date>2015-09-11T18:37:33Z</dc:date>
    <item>
      <title>how to split excel export into separate sheets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-split-excel-export-into-separate-sheets/m-p/225195#M5398</link>
      <description>&lt;P&gt;I have an excel file in which two of the fields are 'Area' and 'Chart_Field_1'.&amp;nbsp; I would like each Area to be exported to an individual Excel file, and for each Chart_Field_1 within that Area to have its own sheet.&amp;nbsp; Any suggestions are greatly appreciated.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 15:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-split-excel-export-into-separate-sheets/m-p/225195#M5398</guid>
      <dc:creator>jmckenzie</dc:creator>
      <dc:date>2015-09-11T15:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to split excel export into separate sheets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-split-excel-export-into-separate-sheets/m-p/225210#M5400</link>
      <description>&lt;P&gt;You might end up with different export statements for each area/chart field option. &amp;nbsp;In the current version of SAS, you can send data to the same file but different sheets by using the "sheet=" option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;something like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc export data=srcdata (where=(area='Area1' and chart_field_1='c1')) file=a1 dbms=xlsx replace; sheet='c1';&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc export data=srcdata (where=(area='Area1' and chart_field_1='c2')) file=a1 dbms=xlsx replace; sheet='c2';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc export data=srcdata (where=(area='Area2' and chart_field_1='c1')) file=a2 dbms=xlsx replace; sheet='c1';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc export data=srcdata (where=(area='Area2' and chart_field_1='c2')) file=a2 dbms=xlsx replace; sheet='c2';&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 18:35:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-split-excel-export-into-separate-sheets/m-p/225210#M5400</guid>
      <dc:creator>DBailey</dc:creator>
      <dc:date>2015-09-11T18:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: how to split excel export into separate sheets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-split-excel-export-into-separate-sheets/m-p/225211#M5401</link>
      <description>If you have a large number of values for "Area" and "Chart_Field_1", you can use a macro to loop through the possible values and output a corresponding Excel workbook for each value of "Area" containing separate spreadsheets for each value of "Chart_Field_1".&lt;BR /&gt;&lt;BR /&gt;To give you some ideas, look at this post: &lt;A href="https://communities.sas.com/t5/SAS-Procedures/Split-SAS-Output-into-multiple-Sheets/td-p/18996" target="_blank"&gt;https://communities.sas.com/t5/SAS-Procedures/Split-SAS-Output-into-multiple-Sheets/td-p/18996&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If the number of variables is small, you could hard-code them.</description>
      <pubDate>Fri, 11 Sep 2015 18:37:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-split-excel-export-into-separate-sheets/m-p/225211#M5401</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2015-09-11T18:37:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to split excel export into separate sheets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/how-to-split-excel-export-into-separate-sheets/m-p/226808#M5428</link>
      <description>&lt;P&gt;I have a large number of variables so I'll need to go the macro route.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what I'm doing, this is what I have so far.&amp;nbsp; What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT= WORK.IDs DATAFILE= "G:\FinUnitReporting\IFASDEMIScombined.xlsx"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=xlsx REPLACE;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SHEET="sheet1";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=YES;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table RawData as&lt;BR /&gt;&amp;nbsp;select *&lt;BR /&gt;&amp;nbsp;from work.IDs;&lt;BR /&gt;&lt;BR /&gt;*;&lt;BR /&gt;%macro rpt(area);&lt;BR /&gt;Proc sql;&lt;BR /&gt;&amp;nbsp; Create table t1 as&lt;BR /&gt;Select * from RawData&lt;BR /&gt;Where area = “&amp;amp;area.”;&lt;BR /&gt;%mend;&lt;BR /&gt;*;&lt;BR /&gt;%put _user_;&lt;BR /&gt;/* for testing&lt;BR /&gt;%rpt(CF1);&lt;BR /&gt;*/&lt;BR /&gt;/*************************************************************&lt;BR /&gt;&amp;nbsp;&amp;nbsp; loop processing&lt;BR /&gt;**************************************************************/&lt;BR /&gt;*;&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table grp1 as&lt;BR /&gt;&amp;nbsp; select distinct area&lt;BR /&gt;&amp;nbsp; from&amp;nbsp; RawData&lt;BR /&gt;&amp;nbsp; order by 1;&lt;BR /&gt;quit;&lt;BR /&gt;filename loops TEMP;&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;FILE LOOPS;&lt;BR /&gt;SET grp1&lt;BR /&gt;&amp;nbsp; PUT '%rpt (' area&amp;nbsp; ');' / '*;';&lt;BR /&gt;run;&lt;BR /&gt;*;&lt;BR /&gt;%inc loops;&lt;BR /&gt;*;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2015 20:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/how-to-split-excel-export-into-separate-sheets/m-p/226808#M5428</guid>
      <dc:creator>jmckenzie</dc:creator>
      <dc:date>2015-09-22T20:38:43Z</dc:date>
    </item>
  </channel>
</rss>

