<?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: I want to read only a few lines from multiple text files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42188#M8660</link>
    <description>review the doc on the infile option FILEVAR=</description>
    <pubDate>Wed, 01 Dec 2010 14:57:05 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2010-12-01T14:57:05Z</dc:date>
    <item>
      <title>I want to read only a few lines from multiple text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42187#M8659</link>
      <description>Suppose I have multiple text files in a directory, and I want to read only a few lines from each and then skip the rest of the text file and move on to the next text file.&lt;BR /&gt;
&lt;BR /&gt;
So, I know I can read multiple files using an INFILE statement something like&lt;BR /&gt;
&lt;BR /&gt;
INFILE 'c:\data\*.txt';&lt;BR /&gt;
&lt;BR /&gt;
followed by the proper input statements. &lt;BR /&gt;
&lt;BR /&gt;
But this reads every line in the file and only goes to the next file when an end-of-file is reached. How can I tell SAS to stop reading one file when a certain text string is found and then advance to the next file without reading each line?</description>
      <pubDate>Wed, 01 Dec 2010 13:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42187#M8659</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-12-01T13:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: I want to read only a few lines from multiple text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42188#M8660</link>
      <description>review the doc on the infile option FILEVAR=</description>
      <pubDate>Wed, 01 Dec 2010 14:57:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42188#M8660</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-12-01T14:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: I want to read only a few lines from multiple text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42189#M8661</link>
      <description>Hi.&lt;BR /&gt;
What is your condition of judgement  when stop read the rest of text file and continue to read next file?</description>
      <pubDate>Thu, 02 Dec 2010 05:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42189#M8661</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2010-12-02T05:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: I want to read only a few lines from multiple text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42190#M8662</link>
      <description>Consider using the DATA step and the INFILE parameters EOV= to detect the new-file start (after reading the first file).  And if you need know the current file-name, use the FILENAME=&lt;VARNAME&gt; parameter (after declaring a LENGTH  for &lt;VARNAME&gt;).&lt;BR /&gt;
&lt;BR /&gt;
Here's an example to read all files that start with FRED*.TXT -- the multiple PUTLOG statements demonstrates SAS behavior with the EOV= being set on the first-record instance, except for the _N_=1 condition:&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
length fileinfo $255;&lt;BR /&gt;
infile 'c:\temp\fred*.txt' end=eof eov=eov filename=fileinfo;&lt;BR /&gt;
input @;&lt;BR /&gt;
putlog '&amp;gt;diag-before&amp;gt;' / _all_;&lt;BR /&gt;
if eov=1 then do;&lt;BR /&gt;
  recnum=0;&lt;BR /&gt;
  eov=0;&lt;BR /&gt;
end;&lt;BR /&gt;
recnum+1;&lt;BR /&gt;
putlog '&amp;gt;diag-after&amp;gt;' / _all_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Review the SAS 9.2 INFILE statement parameter documentation for more details.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/VARNAME&gt;&lt;/VARNAME&gt;</description>
      <pubDate>Fri, 03 Dec 2010 02:53:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42190#M8662</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-12-03T02:53:58Z</dc:date>
    </item>
    <item>
      <title>Re: I want to read only a few lines from multiple text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42191#M8663</link>
      <description>Thanks, Scott, I received a different reply, but this looks interesting as well, and I will test it out.</description>
      <pubDate>Fri, 03 Dec 2010 13:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42191#M8663</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2010-12-03T13:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: I want to read only a few lines from multiple text files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42192#M8664</link>
      <description>when comparing the effect of * in the filename in the infile statement with use of filevar= you should find they both work but being able to switch to the next file at any stage (for example: after reading 5 lines) the FILEVAR= method can read less and so should run faster.</description>
      <pubDate>Sat, 04 Dec 2010 09:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-read-only-a-few-lines-from-multiple-text-files/m-p/42192#M8664</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-12-04T09:48:35Z</dc:date>
    </item>
  </channel>
</rss>

