<?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: Automate Importing multiple files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automate-Importing-multiple-files/m-p/225174#M40402</link>
    <description>Do all the files have the same format? Is it okay if they are imported to the same dataset?&lt;BR /&gt;&lt;BR /&gt;In your current code the _i that should be what? It isn't a macro variable, but should be? You use i, not _i in your loop though.</description>
    <pubDate>Fri, 11 Sep 2015 14:41:50 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-09-11T14:41:50Z</dc:date>
    <item>
      <title>Automate Importing multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-Importing-multiple-files/m-p/209464#M38862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to import numerous files into SAS on multiple times during the month. I would really like to automate this process, but to date have failed to do so. I have to work in a SAS EG 5.1 server environment, which it seems just gives dead-ends with everything I try. The code that I have at the moment follows below. Everything seels to work fine until I try to do the actual import. I have tried importing without using macros, which works fine, but that doesn't solve my problem The macro variable datafile="&amp;amp;FolderPath/&amp;amp;&amp;amp;File&amp;amp;i" resolves to the right values, but when I run the macro, I get the following error (I have tried using PIPE to import the files, but that also doesn't seem to work in the server environment):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Error&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update mode. Temporary parameter values will be saved to &lt;/P&gt;&lt;P&gt;WORK.PARMS.PARMS.SLIST.&lt;/P&gt;&lt;P&gt;ERROR: Physical file does not exist, /sasdata/prototype/card_markerting_analytics/mart/ABMH684/CAMPAIGN &lt;/P&gt;&lt;P&gt;LEADS/PCUBED/Camp46_Apr2015/absa_cc_camp46_targetfile_ntf_absa_nvsc.txt. &lt;/P&gt;&lt;P&gt;ERROR: Import unsuccessful.&amp;nbsp; See SAS Log for details.&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;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;SAS Code&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data List_files;&lt;BR /&gt; rc=FILENAME('FMyRep',"&amp;amp;FolderPath");&lt;BR /&gt; did=DOPEN('FMyRep');&lt;BR /&gt; memcnt=DNUM(did);&lt;BR /&gt; &lt;BR /&gt; DO i=1 TO memcnt;&lt;BR /&gt;&amp;nbsp; filevar=LOWCASE(DREAD(did,i));&lt;BR /&gt; &lt;BR /&gt;&amp;nbsp; IF LOWCASE(SCAN(filevar,-1,".")) EQ LOWCASE("&amp;amp;extension") THEN&lt;BR /&gt;&amp;nbsp;&amp;nbsp; OUTPUT;&lt;BR /&gt; END;&lt;BR /&gt; &lt;BR /&gt; rc=DCLOSE(did);&lt;BR /&gt; rc=FILENAME('FMyRep');&lt;BR /&gt; KEEP filevar;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;DATA test;&lt;BR /&gt; set List_files;&lt;BR /&gt; where index(filevar,'absa_cc');&lt;BR /&gt; Count +1;&lt;BR /&gt; call symputx('File'||left(put(Count , 3.)), filevar, 'l' );&lt;BR /&gt; call symputx('Count', Count , 'l' );&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%put _user_;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt; select count(*) into: numfiles&lt;BR /&gt; from test;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;%macro import();&lt;BR /&gt;%do i = 1 %to &amp;amp;numfiles;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; proc import &lt;BR /&gt;&amp;nbsp; datafile="&amp;amp;FolderPath/&amp;amp;&amp;amp;File&amp;amp;i"&lt;BR /&gt;&amp;nbsp; out=_i&lt;BR /&gt;&amp;nbsp; replace&lt;BR /&gt;&amp;nbsp; dbms=dlm;&lt;BR /&gt;&amp;nbsp; delimiter='|';&lt;BR /&gt; run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;%import();&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;Any help solving this will be greatly appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 08:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-Importing-multiple-files/m-p/209464#M38862</guid>
      <dc:creator>Mince</dc:creator>
      <dc:date>2015-05-05T08:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Automate Importing multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-Importing-multiple-files/m-p/225174#M40402</link>
      <description>Do all the files have the same format? Is it okay if they are imported to the same dataset?&lt;BR /&gt;&lt;BR /&gt;In your current code the _i that should be what? It isn't a macro variable, but should be? You use i, not _i in your loop though.</description>
      <pubDate>Fri, 11 Sep 2015 14:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-Importing-multiple-files/m-p/225174#M40402</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-09-11T14:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Automate Importing multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automate-Importing-multiple-files/m-p/225242#M40414</link>
      <description>&lt;P&gt;The most likely cause of your error is that the directory and file you are trying to import is not accessible from your SAS server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where is /sasdata/prototype etc located? Is it on your SAS server or not? If you are not sure about this ask your SAS administrator.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW you can ignore the NOTE: Unable to open etc. That is a consequence of your SASUSER library being set to read-only, which is the default setup for SAS 9.4.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Sep 2015 01:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automate-Importing-multiple-files/m-p/225242#M40414</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2015-09-12T01:32:50Z</dc:date>
    </item>
  </channel>
</rss>

