<?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 Multiple datasets into on Excel files with Sheet names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Export-Multiple-datasets-into-on-Excel-files-with-Sheet-names/m-p/866432#M342162</link>
    <description>&lt;P&gt;I have two datasets with the same variables and the same formats. How to export them into one excel file with different sheets.&amp;nbsp; Is there any simple way, or do I have to write ODS EXCEL ( or TAGSETS) with PORC REPORT for each dataset? Thank you for your input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the following example, is there any way I can create a macro and loop the required datasets?&amp;nbsp; The following is simple&amp;nbsp; export&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data class1;
 set sashelp.class;
 run;

 data class2;
 set sashelp.class;
 run;


PROC EXPORT DATA= WORK.class1
            OUTFILE= "D:\Desktop\classes.xls" 
            DBMS=EXCEL REPLACE;
     SHEET="Class1"; /* for class2 I have to run it again*/
     NEWFILE=YES;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is how I want two sheets in one excel file&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1679874353546.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82073i33C3180B314EA5C7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1679874353546.png" alt="SASuserlot_0-1679874353546.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 26 Mar 2023 23:46:05 GMT</pubDate>
    <dc:creator>SASuserlot</dc:creator>
    <dc:date>2023-03-26T23:46:05Z</dc:date>
    <item>
      <title>Export Multiple datasets into on Excel files with Sheet names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-Multiple-datasets-into-on-Excel-files-with-Sheet-names/m-p/866432#M342162</link>
      <description>&lt;P&gt;I have two datasets with the same variables and the same formats. How to export them into one excel file with different sheets.&amp;nbsp; Is there any simple way, or do I have to write ODS EXCEL ( or TAGSETS) with PORC REPORT for each dataset? Thank you for your input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the following example, is there any way I can create a macro and loop the required datasets?&amp;nbsp; The following is simple&amp;nbsp; export&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data class1;
 set sashelp.class;
 run;

 data class2;
 set sashelp.class;
 run;


PROC EXPORT DATA= WORK.class1
            OUTFILE= "D:\Desktop\classes.xls" 
            DBMS=EXCEL REPLACE;
     SHEET="Class1"; /* for class2 I have to run it again*/
     NEWFILE=YES;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is how I want two sheets in one excel file&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1679874353546.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82073i33C3180B314EA5C7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1679874353546.png" alt="SASuserlot_0-1679874353546.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2023 23:46:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-Multiple-datasets-into-on-Excel-files-with-Sheet-names/m-p/866432#M342162</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-03-26T23:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple datasets into on Excel files with Sheet names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-Multiple-datasets-into-on-Excel-files-with-Sheet-names/m-p/866435#M342164</link>
      <description>&lt;P&gt;It's a lot easier if you use the XLSX LIBNAME:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class1;
 set sashelp.class;
 run;

 data class2;
 set sashelp.class;
 run;

 libname CLASS XLSX "&amp;lt;MyDir&amp;gt;\Class.xlsx";

 proc datasets library = CLASS;
   copy in = WORK  out = CLASS;
  select class1 class2;
  run;
quit;

libname CLASS clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;No loop needed.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 00:04:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-Multiple-datasets-into-on-Excel-files-with-Sheet-names/m-p/866435#M342164</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-03-27T00:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Export Multiple datasets into on Excel files with Sheet names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Export-Multiple-datasets-into-on-Excel-files-with-Sheet-names/m-p/866438#M342166</link>
      <description>&lt;P&gt;Thank you very much. It served my purpose.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 00:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Export-Multiple-datasets-into-on-Excel-files-with-Sheet-names/m-p/866438#M342166</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-03-27T00:16:31Z</dc:date>
    </item>
  </channel>
</rss>

