<?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 use Proc IMPORT to read multiple .xlsx files? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124772#M34285</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It doesn't make sense to have both.&amp;nbsp; You can either append the files and add in a variable identifying the source file or you can keep them in separate files.&lt;/P&gt;&lt;P&gt;Are you comfortable with macro programming?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Need to get a list of the files you'll need to import. You can do this in SAS using a pipe and a datastep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://support.sas.com/kb/24/820.html" title="http://support.sas.com/kb/24/820.html"&gt;24820 - Creating a Directory Listing Using SAS for Windows&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2. Use SAS to import each workbook with all the sheets.&lt;/P&gt;&lt;P&gt;&lt;A href="http://listserv.uga.edu/cgi-bin/wa?A2=ind1211e&amp;amp;L=sas-l&amp;amp;F=&amp;amp;S=&amp;amp;P=8001"&gt;SAS-L: Importing multiple sheets of excel XLSX File&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can look up the indsname option to keep the source file name when appending multiple files. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Jan 2013 19:57:51 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-01-14T19:57:51Z</dc:date>
    <item>
      <title>How to use Proc IMPORT to read multiple .xlsx files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124768#M34281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Having a data folder with lots of xlsx files, and each xlsx file has several sheets, and one of these sheets is "data1".&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;How to use Proc IMPORT to read multiple .xlsx files? My following code has some problem.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;My SAS:&amp;nbsp; 9.3 (TS1M1), and excel 2010&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let DATAFILE= C:\Users\test\Desktop\test\*.xlsx;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Title "Import multiple .xlsx files";&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;PROC IMPORT OUT= test&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DATAFILE= "&amp;amp;DATAFILE"&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=EXCELCS REPLACE ;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RANGE="data1$";&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCANTEXT=YES;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USEDATE=YES;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCANTIME=YES;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 16:59:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124768#M34281</guid>
      <dc:creator>JeffNCSU</dc:creator>
      <dc:date>2013-01-14T16:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc IMPORT to read multiple .xlsx files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124769#M34282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are reading a single sheet then the SHEET = statement is the usual way:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replace the range =&amp;nbsp; statement with sheet = 'data1';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 18:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124769#M34282</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2013-01-14T18:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc IMPORT to read multiple .xlsx files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124770#M34283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Questions:&lt;/P&gt;&lt;P&gt;Assuming you have multiple files (say X) with multiple sheets.&lt;/P&gt;&lt;P&gt;1. Are they all in the same folder or are some in subfolders?&lt;/P&gt;&lt;P&gt;2. Do all the files have the same structure?&lt;/P&gt;&lt;P&gt;3. Are you planning to have 1 output file or multiple output files (X*something)?&lt;/P&gt;&lt;P&gt;4. If multiple files how are you planning to name them?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 19:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124770#M34283</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-14T19:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc IMPORT to read multiple .xlsx files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124771#M34284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;(1) Some in subfolders. &lt;/P&gt;&lt;P&gt;(2) same structure. &lt;/P&gt;&lt;P&gt;(3)is it possible to have both? or have to use a separate Data procedure to combine them? &lt;/P&gt;&lt;P&gt;(4) Using input file to name them. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 19:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124771#M34284</guid>
      <dc:creator>JeffNCSU</dc:creator>
      <dc:date>2013-01-14T19:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc IMPORT to read multiple .xlsx files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124772#M34285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It doesn't make sense to have both.&amp;nbsp; You can either append the files and add in a variable identifying the source file or you can keep them in separate files.&lt;/P&gt;&lt;P&gt;Are you comfortable with macro programming?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Need to get a list of the files you'll need to import. You can do this in SAS using a pipe and a datastep.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="http://support.sas.com/kb/24/820.html" title="http://support.sas.com/kb/24/820.html"&gt;24820 - Creating a Directory Listing Using SAS for Windows&lt;/A&gt;&lt;/P&gt;&lt;P&gt;2. Use SAS to import each workbook with all the sheets.&lt;/P&gt;&lt;P&gt;&lt;A href="http://listserv.uga.edu/cgi-bin/wa?A2=ind1211e&amp;amp;L=sas-l&amp;amp;F=&amp;amp;S=&amp;amp;P=8001"&gt;SAS-L: Importing multiple sheets of excel XLSX File&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can look up the indsname option to keep the source file name when appending multiple files. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 19:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124772#M34285</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-01-14T19:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc IMPORT to read multiple .xlsx files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124773#M34286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I did similar work a few days ago. below is the code I used. you need to modify the RED parts:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename indata pipe &lt;SPAN style="color: #ff0000;"&gt;'dir N:\"External Investigators Projects"\Libon\"DS Calculator Pilot IDs"&lt;/SPAN&gt; /b ';&lt;/P&gt;&lt;P&gt;/* put all the .xlsx file names in dataset file_list */&lt;BR /&gt;data file_list;&lt;BR /&gt;length fname $90 in_name out_name $32;&lt;BR /&gt;infile indata truncover;&lt;BR /&gt;input fname $ 90.;&lt;BR /&gt;in_name=translate(scan(fname,1,'.'),'_','-');&lt;BR /&gt;out_name=cats('_',in_name); &lt;BR /&gt;if upcase(scan(fname,-1,'.'))='XLSX';&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;&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;&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;&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;run;&lt;BR /&gt;data _null_;&lt;BR /&gt;&amp;nbsp; set file_list end=last;&lt;BR /&gt;&amp;nbsp; call symputx(cats('dsn',_n_),in_name);&lt;BR /&gt;&amp;nbsp; call symputx(cats('outdsn',_n_),out_name);&lt;BR /&gt;&amp;nbsp; if last then call symputx('n',_n_);&lt;BR /&gt; run;&lt;BR /&gt;%macro test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %do i=1 %to &amp;amp;n;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; PROC IMPORT OUT= work.&amp;amp;&amp;amp;outdsn&amp;amp;i.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp; DATAFILE= "N:\External Investigators Projects\Libon\DS Calculator Pilot IDs\&amp;amp;&amp;amp;dsn&amp;amp;i...xlsx" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DBMS=EXCEL REPLACE;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RANGE="Sheet1$E17:E21"; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=NO;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MIXED=NO;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCANTEXT=YES;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USEDATE=YES;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCANTIME=YES;&lt;/SPAN&gt;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%test&lt;/P&gt;&lt;P&gt;data final;&lt;BR /&gt;&amp;nbsp; set _:;&lt;BR /&gt; run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Jan 2013 20:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124773#M34286</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2013-01-14T20:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc IMPORT to read multiple .xlsx files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124774#M34287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Linlin&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I got this error executing your code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: XLSX file does not exist -&amp;gt; D:\file_paht\&amp;amp;&amp;amp;dsn&amp;amp;i...xlsx&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i just tried to execute the code with only 1 file to test the file path and worked well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Mar 2014 19:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124774#M34287</guid>
      <dc:creator>terrabaroni</dc:creator>
      <dc:date>2014-03-09T19:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Proc IMPORT to read multiple .xlsx files?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124775#M34288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the actual ampersands are appearing in your error message then you probably used single quotes (') around your filename instead of double quotes ("). Macro expressions are not evaluated inside of single quotes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2014 03:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-Proc-IMPORT-to-read-multiple-xlsx-files/m-p/124775#M34288</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-10T03:47:33Z</dc:date>
    </item>
  </channel>
</rss>

