<?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: Proc Export vs ODS Excel?  (Creating multiple sheets with ODS excel) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-vs-ODS-Excel-Creating-multiple-sheets-with-ODS-excel/m-p/753915#M237685</link>
    <description>&lt;P&gt;In my experience ODS is resource intensive so I wouldn't use it for large spreadsheets because it likely to be slower. PROC EXPORT or LIBNAME with the XLSX engine are preferable options.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Jul 2021 20:16:45 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2021-07-13T20:16:45Z</dc:date>
    <item>
      <title>Proc Export vs ODS Excel?  (Creating multiple sheets with ODS excel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-vs-ODS-Excel-Creating-multiple-sheets-with-ODS-excel/m-p/753878#M237673</link>
      <description>&lt;P&gt;I am using Enterprise Guide, Version:&amp;nbsp;8.3 (8.3.0.103) (32-bit)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I Have a program similar to the following.&amp;nbsp;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;Though my code has a few additional elements the basics are below.&lt;/P&gt;
&lt;P&gt;Basically it loops through combinations of SubList and TableList, checks if the table exists, and if it does. exports it to its own sheet in an excel file.&lt;/P&gt;
&lt;P&gt;( I typed this fairly quickly, so there may be syntax errors)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname LibPath "C:\Folder1";
%LET PATH = C:\Folder2;

%LET SubList = Sub1 Sub2 Sub3 Sub4 Sub5 Sub6 Sub7 Sub8 Sub9 Sub10;
%LET TableList =	Table1 Table2 Table3 Table4;

%MACRO One();
	%DO J = 1 %TO %SYSFUNC(CountW(&amp;amp;SubList.));
		%LET CurrentSub = %SCAN(&amp;amp;SubList.,&amp;amp;J.);

		%DO K = 1 %TO %SYSFUNC(CountW(&amp;amp;TableList.));
			%LET CurrentTable = %SCAN(&amp;amp;TableList.,&amp;amp;K.);

			%IF %SYSFUNC(EXIST(LibPath.&amp;amp;CurrentSub._&amp;amp;CurrentTable.)) %THEN
				%DO;

					proc sql noprint;
						select Count(*) into :CountObs Trimmed
							from LibPath.&amp;amp;CurrentSub._&amp;amp;CurrentTable;
					quit;

					%IF &amp;amp;CountObs. ^= 0 %THEN
						%DO;

							Proc Export data=LibPath.&amp;amp;CurrentSub._&amp;amp;CurrentTable.
								OutFile="&amp;amp;Path.\OutTable.xslx"
								replace
								DBMS=xlsx;
								SHEET=&amp;amp;CurrentSub._&amp;amp;CurrentTable.;
							run;

						%END;
				%END;
		%END;
	%END;
%MEND One;

%ONE();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;However, Towards the end of the loops, as the excel file gets larger, the Export times increase.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And as this program will be appended to an existing program that already takes 2 or more hours to run, i would like to minimize the run time of this program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, is it possible to achieve this Excel file using ODS Excel? and if so, would it be faster than proc export?&amp;nbsp;&amp;nbsp;&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 18:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Export-vs-ODS-Excel-Creating-multiple-sheets-with-ODS-excel/m-p/753878#M237673</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-07-13T18:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export vs ODS Excel?  (Creating multiple sheets with ODS excel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-vs-ODS-Excel-Creating-multiple-sheets-with-ODS-excel/m-p/753881#M237675</link>
      <description>&lt;P&gt;I haven't gone through your code, but one thing to know about ODS EXCEL is that each time the program runs and comes to ODS EXCEL FILE= ..., a new Excel file is created (and if there was one with the same name, it is gone). Also, with ODS EXCEL, you cannot just write to one tab of an existing table, there really is no ODS EXCEL equivalent to the REPLACE option in PROC EXPORT.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 18:59:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Export-vs-ODS-Excel-Creating-multiple-sheets-with-ODS-excel/m-p/753881#M237675</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-13T18:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export vs ODS Excel?  (Creating multiple sheets with ODS excel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-vs-ODS-Excel-Creating-multiple-sheets-with-ODS-excel/m-p/753901#M237683</link>
      <description>&lt;P&gt;I think a LIBNAME xlsx might be more appropriate. Then you are just copying the data sets into a library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your libname statement might look like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Libname Mylib xlsx "&amp;amp;Path.\OutTable.xslx";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The sheet names would be the name of the data set. Proc copy or any of your favorite ways to move data sets should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make sure to clear the library reference after you write the last data set. Otherwise SAS is still using the file and other programs or users won't be able to use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 19:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Export-vs-ODS-Excel-Creating-multiple-sheets-with-ODS-excel/m-p/753901#M237683</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-13T19:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Export vs ODS Excel?  (Creating multiple sheets with ODS excel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Export-vs-ODS-Excel-Creating-multiple-sheets-with-ODS-excel/m-p/753915#M237685</link>
      <description>&lt;P&gt;In my experience ODS is resource intensive so I wouldn't use it for large spreadsheets because it likely to be slower. PROC EXPORT or LIBNAME with the XLSX engine are preferable options.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 20:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Export-vs-ODS-Excel-Creating-multiple-sheets-with-ODS-excel/m-p/753915#M237685</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-07-13T20:16:45Z</dc:date>
    </item>
  </channel>
</rss>

