<?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: Importing all Excel worksheets into SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122426#M25116</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm curious to know why the Excel LIBNAME does not work for you while PROC IMPORT from Excel does. Both should work fine if your SAS environment is set up correctly for Excel, and SAS/ACCESS to PC FILES is installed and licensed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jul 2013 00:24:43 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2013-07-02T00:24:43Z</dc:date>
    <item>
      <title>Importing all Excel worksheets into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122420#M25110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a code which extract multiple XLS files from a specific folder and imports them into SAS. However the XLS files have the same layout and multiple worksheet, how can I import all worksheet at once into SAS?&lt;/P&gt;&lt;P&gt;I have now hardcoded the sheetname into the code as seen below&amp;nbsp; SHEET="AREA-W"; I would like a dynamic version where SAS will read all worksheet. The layout of the worksheets is identical. How can I achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the code I use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename excellib pipe 'dir F:\IMN /b';&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp; infile excellib truncover end=last;&lt;BR /&gt;&amp;nbsp; /* Edit length as needed */&lt;BR /&gt;&amp;nbsp; length fname $20;&lt;BR /&gt;&amp;nbsp; input fname;&lt;BR /&gt;&amp;nbsp; i+1;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; call symput('fname'||trim(left(put(i,20.))),scan(trim(fname),1,'.'));&lt;BR /&gt;&amp;nbsp; call symput('pext'||trim(left(put(i,20.))),trim(fname));&lt;BR /&gt;&amp;nbsp; if last then call symput('total',trim(left(put(i,15.))));&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro importExcel;&lt;BR /&gt;&amp;nbsp; %do i=1 %to &amp;amp;total;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc import datafile="F:\IMN\&amp;amp;&amp;amp;pext&amp;amp;i" &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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out=work.&amp;amp;&amp;amp;fname&amp;amp;i &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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbms=XLS replace;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SHEET="AREA-W";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getnames=YES ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp; %end;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;/* Invoke the macro */&lt;/P&gt;&lt;P&gt;%importExcel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rishi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jun 2013 14:22:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122420#M25110</guid>
      <dc:creator>RishiThakur</dc:creator>
      <dc:date>2013-06-28T14:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Importing all Excel worksheets into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122421#M25111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't have time to formalize the solution, but you could just expand on the code you already have;&amp;nbsp; You are currently piping in all of the workbook names and your macro already loops through all of the workbooks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within that loop you could assign the workbook to a libref, run a proc contents with an out= option to create a file of the various sheet names, and then simply include a loop that goes through those names and including them in your proc import using the sheet= option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Similarly, rather than running proc contents, the following snippet from the U of Oregon does the same thing using proc sql:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="color: #000000;"&gt;
&lt;P&gt;LIBNAME exbk excel 'c:\sas\excel\test.xls' ;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;/P&gt;
&lt;P&gt;CREATE TABLE sheets AS&lt;/P&gt;
&lt;P&gt;SELECT distinct memname FROM DICTIONARY.COLUMNS&lt;/P&gt;
&lt;P&gt;WHERE libname='EXBK' AND memtype='DATA' and index(memname,'$');&lt;/P&gt;
&lt;P&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; LIBNAME exbk clear; &lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Jun 2013 16:01:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122421#M25111</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-06-28T16:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Importing all Excel worksheets into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122422#M25112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Add something more into Arthur's code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;libname x excel 'c:\temp\xx.xls';

data _null_;
 set sashelp.vmember(where=(libname='X'));
 call execute('data work.n'||strip(_n_)||'; set x.'||quote(dequote(memname))||'n;run;');
run;



&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 29 Jun 2013 13:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122422#M25112</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2013-06-29T13:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Importing all Excel worksheets into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122423#M25113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have a look at the macro I put into another post. It uses the Excel libname to automatically copy all sheets using PROC DATASETS:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://communities.sas.com/message/169998#169998"&gt;https://communities.sas.com/message/169998#169998&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 30 Jun 2013 20:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122423#M25113</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2013-06-30T20:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Importing all Excel worksheets into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122424#M25114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your valuable responses. However I didn't use the libname method as it's not working on my side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to extract the Excel worksheets not using the libname Excel statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rishi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 08:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122424#M25114</guid>
      <dc:creator>RishiThakur</dc:creator>
      <dc:date>2013-07-01T08:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Importing all Excel worksheets into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122425#M25115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are on a version of Windows, you can use DDE.&amp;nbsp; Take a look at: &lt;A href="http://analytics.ncsu.edu/sesug/2003/TU15-Vyverman.pdf" title="http://analytics.ncsu.edu/sesug/2003/TU15-Vyverman.pdf"&gt;http://analytics.ncsu.edu/sesug/2003/TU15-Vyverman.pdf&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Jul 2013 14:50:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122425#M25115</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-07-01T14:50:32Z</dc:date>
    </item>
    <item>
      <title>Re: Importing all Excel worksheets into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122426#M25116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm curious to know why the Excel LIBNAME does not work for you while PROC IMPORT from Excel does. Both should work fine if your SAS environment is set up correctly for Excel, and SAS/ACCESS to PC FILES is installed and licensed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 00:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-all-Excel-worksheets-into-SAS/m-p/122426#M25116</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2013-07-02T00:24:43Z</dc:date>
    </item>
  </channel>
</rss>

