<?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 files ina folder in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12823#M1440</link>
    <description>If i run above code...getting these errors.Can you guide me how to resole that filename statement error.&lt;BR /&gt;
&lt;BR /&gt;
16         %let subdir=C:\Trade-NewSet-06132011\new;&lt;BR /&gt;
17         filename dir pipe "dir &amp;amp;subdir.*.xls /B";&lt;BR /&gt;
ERROR: Insufficient authorization to access PIPE.&lt;BR /&gt;
ERROR: Error in the FILENAME statement.&lt;BR /&gt;
18         data new;&lt;BR /&gt;
19         infile dir truncover end=last;&lt;BR /&gt;
20         input filename  $100.;&lt;BR /&gt;
21         filename=cats("&amp;amp;subdir",filename);&lt;BR /&gt;
22         call symputx(cats('path',_n_),filename);&lt;BR /&gt;
23         call symputx(cats('dsn',_n_),scan(scan(filename,6,'\'),1,'.'));&lt;BR /&gt;
24         if last then call symputx('nobs',_n_);&lt;BR /&gt;
25         run;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: No logical assign for filename DIR.&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
WARNING: The data set WORK.NEW may be incomplete.  When this step was stopped there were 0 &lt;BR /&gt;
         observations and 1 variables.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
     %macro import;&lt;BR /&gt;
28         %do i=1 %to &amp;amp;nobs;&lt;BR /&gt;
29         proc import datafile="&amp;amp;&amp;amp;path&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=excel replace;&lt;BR /&gt;
30         getnames=yes;&lt;BR /&gt;
31         mixed=yes;&lt;BR /&gt;
32         run;&lt;BR /&gt;
33         %end;&lt;BR /&gt;
34         %mend import;&lt;BR /&gt;
WARNING: Apparent symbolic reference NOBS not resolved.&lt;BR /&gt;
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric &lt;BR /&gt;
       operand is required. The condition was: &amp;amp;nobs &lt;BR /&gt;
ERROR: The %TO value of the %DO I loop is invalid.&lt;BR /&gt;
ERROR: The macro IMPORT will stop executing.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
brm.</description>
    <pubDate>Tue, 14 Jun 2011 05:41:42 GMT</pubDate>
    <dc:creator>brm</dc:creator>
    <dc:date>2011-06-14T05:41:42Z</dc:date>
    <item>
      <title>importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12820#M1437</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
 I have 6 excel files in one folder ex: c:/data.....I want to import all those files into SAS.&lt;BR /&gt;
&lt;BR /&gt;
Can somebody help me with the code,how can i do it with programming,instead of importing each file.&lt;BR /&gt;
&lt;BR /&gt;
one more thing,is there anyway we can import(only one file which is added to that folder later using program).&lt;BR /&gt;
&lt;BR /&gt;
Please somebody help me.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
brm</description>
      <pubDate>Mon, 13 Jun 2011 23:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12820#M1437</guid>
      <dc:creator>brm</dc:creator>
      <dc:date>2011-06-13T23:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12821#M1438</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
You can use the x command to create a text file listing the contents of your directory then importing it to a dataset. Create also a flag that would help you identify that the excel file is not yet loaded.&lt;BR /&gt;
&lt;BR /&gt;
After this you can create a loop which iterates over that dataset as your input parameter on proc import.&lt;BR /&gt;
&lt;BR /&gt;
After this flag the read items that it has already been imported. &lt;BR /&gt;
&lt;BR /&gt;
If I have a free time I'll try to post the actual code here.&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps. Feel free to comment is it sounds confusing&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Milton</description>
      <pubDate>Tue, 14 Jun 2011 00:53:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12821#M1438</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2011-06-14T00:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12822#M1439</link>
      <description>[pre]&lt;BR /&gt;
%let subdir=D:\sasdata\;&lt;BR /&gt;
filename dir pipe "dir &amp;amp;subdir.*.xls /B";&lt;BR /&gt;
data new;&lt;BR /&gt;
 infile dir truncover end=last;&lt;BR /&gt;
 input filename  $100.;&lt;BR /&gt;
 filename=cats("&amp;amp;subdir",filename);&lt;BR /&gt;
 call symputx(cats('path',_n_),filename);&lt;BR /&gt;
 call symputx(cats('dsn',_n_),scan(scan(filename,6,'\'),1,'.'));&lt;BR /&gt;
 if last then call symputx('nobs',_n_);&lt;BR /&gt;
run;&lt;BR /&gt;
%put _user_;&lt;BR /&gt;
%macro import;&lt;BR /&gt;
%do i=1 %to &amp;amp;nobs;&lt;BR /&gt;
proc import datafile="&amp;amp;&amp;amp;path&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=excel replace;&lt;BR /&gt;
                                              getnames=yes;&lt;BR /&gt;
                                              mixed=yes;&lt;BR /&gt;
                                              run;&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend import;&lt;BR /&gt;
&lt;BR /&gt;
%import&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 14 Jun 2011 05:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12822#M1439</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-14T05:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12823#M1440</link>
      <description>If i run above code...getting these errors.Can you guide me how to resole that filename statement error.&lt;BR /&gt;
&lt;BR /&gt;
16         %let subdir=C:\Trade-NewSet-06132011\new;&lt;BR /&gt;
17         filename dir pipe "dir &amp;amp;subdir.*.xls /B";&lt;BR /&gt;
ERROR: Insufficient authorization to access PIPE.&lt;BR /&gt;
ERROR: Error in the FILENAME statement.&lt;BR /&gt;
18         data new;&lt;BR /&gt;
19         infile dir truncover end=last;&lt;BR /&gt;
20         input filename  $100.;&lt;BR /&gt;
21         filename=cats("&amp;amp;subdir",filename);&lt;BR /&gt;
22         call symputx(cats('path',_n_),filename);&lt;BR /&gt;
23         call symputx(cats('dsn',_n_),scan(scan(filename,6,'\'),1,'.'));&lt;BR /&gt;
24         if last then call symputx('nobs',_n_);&lt;BR /&gt;
25         run;&lt;BR /&gt;
&lt;BR /&gt;
ERROR: No logical assign for filename DIR.&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
WARNING: The data set WORK.NEW may be incomplete.  When this step was stopped there were 0 &lt;BR /&gt;
         observations and 1 variables.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
     %macro import;&lt;BR /&gt;
28         %do i=1 %to &amp;amp;nobs;&lt;BR /&gt;
29         proc import datafile="&amp;amp;&amp;amp;path&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=excel replace;&lt;BR /&gt;
30         getnames=yes;&lt;BR /&gt;
31         mixed=yes;&lt;BR /&gt;
32         run;&lt;BR /&gt;
33         %end;&lt;BR /&gt;
34         %mend import;&lt;BR /&gt;
WARNING: Apparent symbolic reference NOBS not resolved.&lt;BR /&gt;
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric &lt;BR /&gt;
       operand is required. The condition was: &amp;amp;nobs &lt;BR /&gt;
ERROR: The %TO value of the %DO I loop is invalid.&lt;BR /&gt;
ERROR: The macro IMPORT will stop executing.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
brm.</description>
      <pubDate>Tue, 14 Jun 2011 05:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12823#M1440</guid>
      <dc:creator>brm</dc:creator>
      <dc:date>2011-06-14T05:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12824#M1441</link>
      <description>Searching the SAS.COM support website, you will need to contact your SAS admin for assistance -  here is a Google advanced search argument that revealed a SAS USAGE NOTE:&lt;BR /&gt;
&lt;BR /&gt;
ERROR: Insufficient authorization to access PIPE site:sas.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Usage Note 16109: Insufficient Authorization to access pipe error message when connecting to Spawner programs&lt;BR /&gt;
&lt;A href="http://support.sas.com/kb/16/109.html" target="_blank"&gt;http://support.sas.com/kb/16/109.html&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 14 Jun 2011 11:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12824#M1441</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-06-14T11:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12825#M1442</link>
      <description>Besides of the noxcmd issue:&lt;BR /&gt;
&lt;BR /&gt;
If this is a once-off task and nothing repetitive then use EG's import wizard instead of coding.&lt;BR /&gt;
&lt;BR /&gt;
Reason: The import wizard does also some data cleansing for you like removing control characters in text fields and the like. I had just lately "a lot of fun" doing this programatically.&lt;BR /&gt;
&lt;BR /&gt;
The wizard allows you also to embed your source data into the code in case you want to re-run things later on - so the import wizard step has only to be done once.&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick

Message was edited by: Patrick</description>
      <pubDate>Tue, 14 Jun 2011 11:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12825#M1442</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2011-06-14T11:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12826#M1443</link>
      <description>From your log, it looks like you can not use PIPE function which maybe be deny by Administrator.&lt;BR /&gt;
Are you using SAS/EG or other SAS client software? If you can ,let Administrator to open it, If you can not ,You can use dopen() fopen() and so on ,these are mentioned by SASKiwi before, search it in forum ,you will find answer.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 17 Jun 2011 05:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12826#M1443</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-17T05:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12827#M1444</link>
      <description>Or you can use filename *.xls to get list of xls filename. &lt;BR /&gt;
This is an example.Not test fully.&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
%let subdir=c:\temp\;&lt;BR /&gt;
filename dir  "&amp;amp;subdir.*.xls ";&lt;BR /&gt;
data new;&lt;BR /&gt;
 length filename  fname $ 50;&lt;BR /&gt;
 infile dir  eof=last filename=fname;&lt;BR /&gt;
 input ;&lt;BR /&gt;
 last: filename=fname; &lt;BR /&gt;
run; &lt;BR /&gt;
proc sort data=new nodupkey;&lt;BR /&gt;
 by filename;&lt;BR /&gt;
run;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
 set new;&lt;BR /&gt;
 call symputx(cats('filename',_n_),filename);&lt;BR /&gt;
 call symputx(cats('dsn',_n_),compress(scan(filename,-2,'\.'), ,'ka');&lt;BR /&gt;
 if last then call symputx('nobs',_n_);&lt;BR /&gt;
run;&lt;BR /&gt;
%put _user_;&lt;BR /&gt;
%macro import;&lt;BR /&gt;
%do i=1 %to &amp;amp;nobs;&lt;BR /&gt;
proc import datafile="&amp;amp;&amp;amp;filename&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=excel replace;&lt;BR /&gt;
                                              getnames=yes;&lt;BR /&gt;
                                              mixed=yes;&lt;BR /&gt;
                                              run;&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend import;&lt;BR /&gt;
&lt;BR /&gt;
%import&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 20 Jun 2011 04:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12827#M1444</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-20T04:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12828#M1445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I changed a few things to Ksharp's answer and it worked for me:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let subdir=C:\path\;&lt;/P&gt;&lt;P&gt;filename dir&amp;nbsp; "&amp;amp;subdir.*.xlsx ";&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;length filename&amp;nbsp; fname $ 200;&lt;/P&gt;&lt;P&gt;infile dir&amp;nbsp; eof=last filename=fname;&lt;/P&gt;&lt;P&gt;input ;&lt;/P&gt;&lt;P&gt;last: filename=fname;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=new nodupkey;&lt;/P&gt;&lt;P&gt;by filename;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data null;&lt;/P&gt;&lt;P&gt;set new;&lt;/P&gt;&lt;P&gt;call symputx(cats('filename',_n_),filename);&lt;/P&gt;&lt;P&gt;call symputx(cats('dsn',_n_),compress(scan(filename,-2,'\.'), ,'ka'));&lt;/P&gt;&lt;P&gt;call symputx('nobs',_n_);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;nobs.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro import;&lt;/P&gt;&lt;P&gt;%do i=1 %to &amp;amp;nobs;&lt;/P&gt;&lt;P&gt;proc import datafile="&amp;amp;&amp;amp;filename&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=excel replace;&lt;/P&gt;&lt;P&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;&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; getnames=yes;&lt;/P&gt;&lt;P&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;&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; mixed=yes;&lt;/P&gt;&lt;P&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;&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; run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend import;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%import&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2014 19:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12828#M1445</guid>
      <dc:creator>ernie2014</dc:creator>
      <dc:date>2014-05-21T19:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12829#M1446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The %for Macro will answer the original question (and work on subfolders as well)&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://www.sascommunity.org/wiki/Streamlining_Data-Driven_SAS_With_The_%25FOR_Macro"&gt;http://www.sascommunity.org/wiki/Streamlining_Data-Driven_SAS_With_The_%25FOR_Macro&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 May 2014 20:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12829#M1446</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2014-05-21T20:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12830#M1447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi PaigeMiller,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;%let topfolderpath=C:\Users\Desktop\Test_Import;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%for(filepath, in=&amp;lt;&amp;amp;topfolderpath&amp;gt;, do=%nrstr(&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let subfolderpath=&amp;amp;filepath;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %for(filepath shortname, in=&amp;lt;&amp;amp;subfolderpath&amp;gt;, do=%nrstr(&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc import out=&amp;amp;shortname&lt;/P&gt;&lt;P&gt;&amp;nbsp; datafile="&amp;amp;filepath"&lt;/P&gt;&lt;P&gt;&amp;nbsp; DBMS=EXCEL REPLACE;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RANGE="ALL_INJ$";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GETNAMES=YES;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MIXED=NO;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCANTEXT=YES;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; USEDATE=YES;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SCANTIME=YES;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ))&lt;/P&gt;&lt;P&gt;))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I got this error. I tested these paths given below and they should work fine.&lt;/P&gt;&lt;P&gt;ERROR: cant open directory path=C:\Users\Desktop\Test_Import\all_inj_8-28-14.xlsx&lt;/P&gt;&lt;P&gt;ERROR: cant open directory path=C:\Users\Desktop\Test_Import\all_inj_8_26_14.xlsx&lt;/P&gt;&lt;P&gt;ERROR: cant open directory path=C:\Users\Desktop\Test_Import\all_inj_8_27_14.xlsx&lt;/P&gt;&lt;P&gt;ERROR: cant open directory path=C:\Users\Desktop\Test_Import\all_inj_9-2-14.xlsx&lt;/P&gt;&lt;P&gt;ERROR: cant open directory path=C:\Users\Desktop\Test_Import\all_inj_9-3-14.xlsx&lt;/P&gt;&lt;P&gt;ERROR: cant open directory path=C:\Users\Desktop\Test_Import\all_inj_9-4-14.xlsx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Sep 2014 17:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/12830#M1447</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2014-09-05T17:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/304844#M64931</link>
      <description>&lt;P&gt;Hi, I tried exactly the same syntax that you posted and got error messages highlighting the "=" in the "dbms=excel" Would appreciate help with what I need to change. Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE 137-205: Line generated by the invoked macro "IMPORT".&lt;BR /&gt;35 proc import datafile="&amp;amp;&amp;amp;filename&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=excel replace;&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;35 ! getnames=yes; mixed=yes;&lt;BR /&gt;35 ! run;&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: DATAFILE, DATATABLE, DBMS, FILE, OUT,&lt;BR /&gt;TABLE.&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "IMPORT".&lt;BR /&gt;35 proc import datafile="&amp;amp;&amp;amp;filename&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=excel replace;&lt;BR /&gt;-&lt;BR /&gt;76&lt;BR /&gt;35 ! getnames=yes; mixed=yes;&lt;BR /&gt;35 ! run;&lt;BR /&gt;ERROR 76-322: Syntax error, statement will be ignored.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 04:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/304844#M64931</guid>
      <dc:creator>myng</dc:creator>
      <dc:date>2016-10-15T04:03:43Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/417062#M102426</link>
      <description>&lt;P&gt;thanks for sharing this Sir&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 14:29:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/417062#M102426</guid>
      <dc:creator>anup_sas</dc:creator>
      <dc:date>2017-11-29T14:29:31Z</dc:date>
    </item>
    <item>
      <title>Re: importing all excel files ina folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/471443#M120761</link>
      <description>&lt;P&gt;Can you please explain (eof and filename) in the below code ?&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;%let subdir=c:\temp\;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;filename dir "&amp;amp;subdir.*.xls ";&lt;/SPAN&gt;&lt;BR /&gt;data new;
length filename fname $ 50;
infile dir eof=last filename=fname;
input ;
last: filename=fname; 
run; &lt;/PRE&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 17:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/importing-all-excel-files-ina-folder/m-p/471443#M120761</guid>
      <dc:creator>Vibhaa</dc:creator>
      <dc:date>2018-06-19T17:06:43Z</dc:date>
    </item>
  </channel>
</rss>

