<?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: Read unknown number .dat of batch files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-unknown-number-dat-of-batch-files/m-p/344799#M79265</link>
    <description>&lt;P&gt;The macro you pasted only creates a list of files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe this maybe more helpful?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not, search on here, at least 3 solutions to this problem in last week.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Mar 2017 21:03:42 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-03-27T21:03:42Z</dc:date>
    <item>
      <title>Read unknown number .dat of batch files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-unknown-number-dat-of-batch-files/m-p/344792#M79261</link>
      <description>&lt;P&gt;I have an unknown number of files to read in from the F:\DATA directory. &amp;nbsp;The following code is directly from SAS documentation... but I can't dicipher how to make it work for my directory where the file names are .dat extentions with an unknown/unlimited number batch files. &amp;nbsp; Where do I put my infile statement, and where do I specify the file names (data01.dat, data02.dat, data03.dat....etc.)?&lt;/P&gt;
&lt;P&gt;Thank you for any help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LAN directory&amp;nbsp;%macro drive(dir,ext); &lt;BR /&gt; %local filrf rc did memcnt name i; &lt;BR /&gt; &lt;BR /&gt; /* Assigns a fileref to the directory and opens the directory */ &lt;BR /&gt; %let rc=%sysfunc(filename(filrf,&amp;amp;dir)); &lt;BR /&gt; %let did=%sysfunc(dopen(&amp;amp;filrf)); &lt;BR /&gt; &lt;BR /&gt; /* Make sure directory can be open */ &lt;BR /&gt; %if &amp;amp;did eq 0 %then %do; &lt;BR /&gt; %put Directory &amp;amp;dir cannot be open or does not exist; &lt;BR /&gt; %return; &lt;BR /&gt; %end; &lt;BR /&gt; &lt;BR /&gt; /* Loops through entire directory */ &lt;BR /&gt; %do i = 1 %to %sysfunc(dnum(&amp;amp;did)); &lt;BR /&gt; &lt;BR /&gt; /* Retrieve name of each file */ &lt;BR /&gt; %let name=%qsysfunc(dread(&amp;amp;did,&amp;amp;i)); &lt;BR /&gt; &lt;BR /&gt; /* Checks to see if the extension matches the parameter value */ &lt;BR /&gt; /* If condition is true print the full name to the log */ &lt;BR /&gt; %if %qupcase(%qscan(&amp;amp;name,-1,.)) = %upcase(&amp;amp;ext) %then %do; &lt;BR /&gt; %put &amp;amp;dir\&amp;amp;name; &lt;BR /&gt; %end; &lt;BR /&gt; /* If directory name call macro again */ &lt;BR /&gt; %else %if %qscan(&amp;amp;name,2,.) = %then %do; &lt;BR /&gt; %drive(&amp;amp;dir\%unquote(&amp;amp;name),&amp;amp;ext) &lt;BR /&gt; %end; &lt;BR /&gt; &lt;BR /&gt; %end; &lt;BR /&gt; &lt;BR /&gt; /* Closes the directory and clear the fileref */ &lt;BR /&gt; %let rc=%sysfunc(dclose(&amp;amp;did)); &lt;BR /&gt; %let rc=%sysfunc(filename(filrf)); &lt;BR /&gt; &lt;BR /&gt;%mend drive; &lt;BR /&gt; &lt;BR /&gt;/* First parameter is the directory of where your files are stored. */ &lt;BR /&gt;/* Second parameter is the extension you are looking for. */ &lt;BR /&gt;%drive(F:\Viking45\DATA,sas) &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 20:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-unknown-number-dat-of-batch-files/m-p/344792#M79261</guid>
      <dc:creator>jakestat</dc:creator>
      <dc:date>2017-03-27T20:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: Read unknown number .dat of batch files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-unknown-number-dat-of-batch-files/m-p/344799#M79265</link>
      <description>&lt;P&gt;The macro you pasted only creates a list of files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe this maybe more helpful?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If not, search on here, at least 3 solutions to this problem in last week.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 21:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-unknown-number-dat-of-batch-files/m-p/344799#M79265</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-27T21:03:42Z</dc:date>
    </item>
  </channel>
</rss>

