<?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 Export to multiple XLSX files and multiple sheets in Each file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Export-to-multiple-XLSX-files-and-multiple-sheets-in-Each-file/m-p/746950#M234398</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I want to create multiple XLSX files and in each file multiple sheets.&lt;/P&gt;
&lt;P&gt;I want to work on data set&amp;nbsp;sashelp.cars.&lt;/P&gt;
&lt;P&gt;For each "Make" to have a seprate XLSX file with name&amp;nbsp; of the make(for example: File&amp;nbsp;Audi,BMW,Cadillac and so on).&lt;/P&gt;
&lt;P&gt;Within Each file there will be multiple folder by "Type" (For example:Sedan,SUV,Sports and so on).&lt;/P&gt;
&lt;P&gt;What is the best way to do it please and may you please show full code?&lt;/P&gt;
&lt;P&gt;In each sheet there will be raw data for this Make+Type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This vode here is not good because it create only one XLSX file with multiple sheets (by type+make).&lt;/P&gt;
&lt;P&gt;I want to create multiple XLSX files and in each file multiple sheets by type&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=work.cars;
   by Type Make;
run;
ods excel file="/path/CCC.xlsx"
options(sheet_interval='bygroup');
proc print data=work.cars;
 by Type Make;
run;
ods excel close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;J&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jun 2021 08:28:51 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2021-06-10T08:28:51Z</dc:date>
    <item>
      <title>Export to multiple XLSX files and multiple sheets in Each file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-to-multiple-XLSX-files-and-multiple-sheets-in-Each-file/m-p/746950#M234398</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I want to create multiple XLSX files and in each file multiple sheets.&lt;/P&gt;
&lt;P&gt;I want to work on data set&amp;nbsp;sashelp.cars.&lt;/P&gt;
&lt;P&gt;For each "Make" to have a seprate XLSX file with name&amp;nbsp; of the make(for example: File&amp;nbsp;Audi,BMW,Cadillac and so on).&lt;/P&gt;
&lt;P&gt;Within Each file there will be multiple folder by "Type" (For example:Sedan,SUV,Sports and so on).&lt;/P&gt;
&lt;P&gt;What is the best way to do it please and may you please show full code?&lt;/P&gt;
&lt;P&gt;In each sheet there will be raw data for this Make+Type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This vode here is not good because it create only one XLSX file with multiple sheets (by type+make).&lt;/P&gt;
&lt;P&gt;I want to create multiple XLSX files and in each file multiple sheets by type&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=work.cars;
   by Type Make;
run;
ods excel file="/path/CCC.xlsx"
options(sheet_interval='bygroup');
proc print data=work.cars;
 by Type Make;
run;
ods excel close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;J&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 08:28:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-to-multiple-XLSX-files-and-multiple-sheets-in-Each-file/m-p/746950#M234398</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-10T08:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Export to multiple XLSX files and multiple sheets in Each file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-to-multiple-XLSX-files-and-multiple-sheets-in-Each-file/m-p/746958#M234401</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=SASHELP.cars;
by made type;
run;


PROC SQL noprint;
	select  distinct made into :Vector separated by '+'	   
	from  SASHELP.cars
;
QUIT;
%put &amp;amp;Vector;
%let n= %sysfunc(countw(&amp;amp;Vector));
%put &amp;amp;n;

%macro exportMacro; 
%do j=1 %to &amp;amp;n.;
%let made=%scan(&amp;amp;Vector.,&amp;amp;j.,+);
ods excel file="/path/made_&amp;amp;made..xlsx"
options(sheet_interval='bygroup');
proc print data=SASHELP.cars(where=(made=&amp;amp;made.));
by type;
run;
ods excel close;
%end;
%mend;
%exportMacro;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code works 100% fine for me but my question if there is a more coefficient way to do it without create macro var&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 08:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-to-multiple-XLSX-files-and-multiple-sheets-in-Each-file/m-p/746958#M234401</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-10T08:53:46Z</dc:date>
    </item>
  </channel>
</rss>

