<?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: [Data step] read records starting with '1' only in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35793#M7071</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For 2 helpful statements &lt;/P&gt;&lt;OL start="1"&gt;&lt;LI&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm"&gt;INFILE&lt;/A&gt;&amp;nbsp; defines the file to read&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146292.htm"&gt;INPUT&lt;/A&gt;&amp;nbsp; defines the fields you read from the file&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;you'll find examples and (the very broad) syntax in SAS documentation at these links&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your example, something like the following might work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile 'd:\your\folders\and_file' truncover ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input @1 record_type $char1. @ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if record_type NE '1' then delete ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input stuff $ ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;good luck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Oct 2011 10:04:18 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2011-10-27T10:04:18Z</dc:date>
    <item>
      <title>[Data step] read records starting with '1' only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35792#M7070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to use data step to input the following data records &lt;SPAN style="color: #000000; text-decoration: underline;"&gt;(contained in a text file)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0#startambs&lt;/P&gt;&lt;P&gt;1Peter 13 pilot pass&lt;/P&gt;&lt;P&gt;1Mary 14 teacher pass&lt;/P&gt;&lt;P&gt;2#end ambs&lt;/P&gt;&lt;P&gt;0#startambs&lt;/P&gt;&lt;P&gt;1John 16 pilot pass&lt;/P&gt;&lt;P&gt;1Susan 18 teacher pass&lt;/P&gt;&lt;P&gt;2#end ambs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first digit indicates the property of record. 0 = header, 1=actual data 2=trailer.&lt;/P&gt;&lt;P&gt;I only need to input actual data only. i.e. only read records starting with 1, ignore those start with 0 or 2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what can i write in the code?&lt;/P&gt;&lt;P&gt;I think i can use an infile statement, but i dont know how to set condition to read records starting with 1 only&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2011 09:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35792#M7070</guid>
      <dc:creator>DerekChan</dc:creator>
      <dc:date>2011-10-27T09:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: [Data step] read records starting with '1' only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35793#M7071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For 2 helpful statements &lt;/P&gt;&lt;OL start="1"&gt;&lt;LI&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146932.htm"&gt;INFILE&lt;/A&gt;&amp;nbsp; defines the file to read&lt;/LI&gt;&lt;LI&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000146292.htm"&gt;INPUT&lt;/A&gt;&amp;nbsp; defines the fields you read from the file&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;you'll find examples and (the very broad) syntax in SAS documentation at these links&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your example, something like the following might work&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; infile 'd:\your\folders\and_file' truncover ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input @1 record_type $char1. @ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if record_type NE '1' then delete ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input stuff $ ;&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;good luck&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2011 10:04:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35793#M7071</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-10-27T10:04:18Z</dc:date>
    </item>
    <item>
      <title>[Data step] read records starting with '1' only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35794#M7072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will do the job:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: navy; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;DATA &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;AAA ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;drop&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; lead;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;length&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; Lead &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;3&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; name $ &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;10&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; age &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;3&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; prof $ &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;10&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;res $ &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;10&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;INPUT&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; @&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; LEAD &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;1.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;@;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; Lead=&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;1&lt;/SPAN&gt;&lt;/STRONG&gt; &lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;then &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;input&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; @&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;2&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt; name : &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: teal; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;$10. &lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;age prof&amp;nbsp; res ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="color: blue; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;DATALINES&lt;/SPAN&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: white; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: #ffffc0; font-family: 'Courier New'; font-size: 10pt;"&gt;0#startambs&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: #ffffc0; font-family: 'Courier New'; font-size: 10pt;"&gt;1Peter 13 pilot pass&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: #ffffc0; font-family: 'Courier New'; font-size: 10pt;"&gt;1Mary 14 teacher pass&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: #ffffc0; font-family: 'Courier New'; font-size: 10pt;"&gt;2#end ambs&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: #ffffc0; font-family: 'Courier New'; font-size: 10pt;"&gt;0#startambs&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: #ffffc0; font-family: 'Courier New'; font-size: 10pt;"&gt;1John 16 pilot pass&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN lang="EN-US" style="color: black; background-color: #ffffc0; font-family: 'Courier New'; font-size: 10pt;"&gt;1Susan 18 teacher pass&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="color: black; background-color: #ffffc0; font-family: 'Courier New'; font-size: 10pt;"&gt;2#end ambs&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;hobbes&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2011 10:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35794#M7072</guid>
      <dc:creator>Hobbes</dc:creator>
      <dc:date>2011-10-27T10:06:40Z</dc:date>
    </item>
    <item>
      <title>[Data step] read records starting with '1' only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35795#M7073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How about:&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;PRE&gt;filename x 'c:\x.txt';
data want;
infile x truncover length=len;
input row $varying200. len;
if left(row) eq: '1';
run;

&lt;/PRE&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;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2011 10:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35795#M7073</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-10-27T10:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: [Data step] read records starting with '1' only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35796#M7074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data foo;&lt;/P&gt;&lt;P&gt; infile '/temp/foo.txt' truncover length=len;&lt;/P&gt;&lt;P&gt; input @;&lt;/P&gt;&lt;P&gt; if prxmatch('/^1/',_infile_)&amp;gt;0 then row=_infile_; else delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Oct 2011 17:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-step-read-records-starting-with-1-only/m-p/35796#M7074</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2011-10-27T17:01:50Z</dc:date>
    </item>
  </channel>
</rss>

