<?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 Reading in .dat file with extraneous data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74283#M16019</link>
    <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to pull data from a .dat file based on pattern matching criteria.  This file has extra info about locations, conditions, instruments, etc. at the start of the file, but the data I want is further down.  I am able to using matching criteria to obtain the first line of data, but then it stops after that line because the match no longer applies.&lt;BR /&gt;
Ex:&lt;BR /&gt;
 ** Today's data file &lt;BR /&gt;
   Location = river brook&lt;BR /&gt;
   Three staff present&lt;BR /&gt;
   Lamprey tracking project&lt;BR /&gt;
&lt;BR /&gt;
 Date         Time     Location    Sample     Total&lt;BR /&gt;
03/08/10    08:10     001            034          56&lt;BR /&gt;
03/08/10    08:15     001            035          56&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data counts;&lt;BR /&gt;
	infile 'C:\mydata\file.dat';&lt;BR /&gt;
	input @'Location  Sample  Total ' date time $8. location sample total;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to match to read the first line and then continue reading until the end?  Or some other way to pull only certain info form this file?  Thank you for any suggestions!

Message was edited by: Tiffany</description>
    <pubDate>Thu, 08 Apr 2010 14:22:16 GMT</pubDate>
    <dc:creator>Tiffany</dc:creator>
    <dc:date>2010-04-08T14:22:16Z</dc:date>
    <item>
      <title>Reading in .dat file with extraneous data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74283#M16019</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
I am trying to pull data from a .dat file based on pattern matching criteria.  This file has extra info about locations, conditions, instruments, etc. at the start of the file, but the data I want is further down.  I am able to using matching criteria to obtain the first line of data, but then it stops after that line because the match no longer applies.&lt;BR /&gt;
Ex:&lt;BR /&gt;
 ** Today's data file &lt;BR /&gt;
   Location = river brook&lt;BR /&gt;
   Three staff present&lt;BR /&gt;
   Lamprey tracking project&lt;BR /&gt;
&lt;BR /&gt;
 Date         Time     Location    Sample     Total&lt;BR /&gt;
03/08/10    08:10     001            034          56&lt;BR /&gt;
03/08/10    08:15     001            035          56&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data counts;&lt;BR /&gt;
	infile 'C:\mydata\file.dat';&lt;BR /&gt;
	input @'Location  Sample  Total ' date time $8. location sample total;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to match to read the first line and then continue reading until the end?  Or some other way to pull only certain info form this file?  Thank you for any suggestions!

Message was edited by: Tiffany</description>
      <pubDate>Thu, 08 Apr 2010 14:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74283#M16019</guid>
      <dc:creator>Tiffany</dc:creator>
      <dc:date>2010-04-08T14:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in .dat file with extraneous data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74284#M16020</link>
      <description>From the data-sample you provided, there will be no match - where is the string "Events " in your input?&lt;BR /&gt;
&lt;BR /&gt;
Get your INPUT stmt @'&lt;SEARCH_CRITERIA&gt;'  sorted out and then use the END=EOF parameter on the INFILE statement, and code a DO / END loop logic after you get the record pointer to the start of your data.  You will likely have at least two INPUT statements, one outside the DO loop (ahead to get to the desired input location) and another (one or more as needed) to perform the data record INPUT processing.&lt;BR /&gt;
&lt;BR /&gt;
For self-checking, suggest adding one or more PUTLOG commands in your code at various points (use "nnn" to identify each uniquely):&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG '&amp;gt;DIAG-nnn&amp;gt;' / _all_;&lt;BR /&gt;
&lt;BR /&gt;
..and/or...&lt;BR /&gt;
&lt;BR /&gt;
PUTLOG '&amp;gt;DIAG-nnn&amp;gt;' / _infile_;&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/SEARCH_CRITERIA&gt;</description>
      <pubDate>Thu, 08 Apr 2010 14:33:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74284#M16020</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-04-08T14:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in .dat file with extraneous data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74285#M16021</link>
      <description>Thank you Scott!&lt;BR /&gt;
&lt;BR /&gt;
This is what I have now, but I am still missing something critical:&lt;BR /&gt;
&lt;BR /&gt;
data counts;&lt;BR /&gt;
infile 'C:\mydata\file.dat' end=eof;&lt;BR /&gt;
input @'Location Sample Total ' date time $8. location sample total;&lt;BR /&gt;
   do until (eof);&lt;BR /&gt;
     input date time $8. location sample total;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
any thoughts?</description>
      <pubDate>Thu, 08 Apr 2010 14:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74285#M16021</guid>
      <dc:creator>Tiffany</dc:creator>
      <dc:date>2010-04-08T14:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in .dat file with extraneous data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74286#M16022</link>
      <description>[pre]&lt;BR /&gt;
data counts;&lt;BR /&gt;
   infile 'C:\mydata\file.dat' end=eof;&lt;BR /&gt;
   input @'Location Sample Total ' date time $8. location sample total;&lt;BR /&gt;
   do until (eof);&lt;BR /&gt;
      input date time $8. location sample total;&lt;BR /&gt;
      &lt;B&gt;&lt;I&gt;output;&lt;/I&gt;&lt;/B&gt;&lt;BR /&gt;
      end;&lt;BR /&gt;
   stop;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 08 Apr 2010 15:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74286#M16022</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-04-08T15:49:31Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in .dat file with extraneous data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74287#M16023</link>
      <description>perfect. thank you!</description>
      <pubDate>Thu, 08 Apr 2010 16:04:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-dat-file-with-extraneous-data/m-p/74287#M16023</guid>
      <dc:creator>Tiffany</dc:creator>
      <dc:date>2010-04-08T16:04:19Z</dc:date>
    </item>
  </channel>
</rss>

