<?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: reading from buffer in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271114#M58293</link>
    <description>&lt;P&gt;Yes you could redirect the result to a different data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data good (drop= LongStr test)&amp;nbsp;bad (keep=LongStr);&amp;nbsp; /*&amp;lt;= TWO separate data sets that will have different variables*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Length LongStr $ 200; /*large enough to hold the longest expected _infile_ result*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; infile file;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; length test $ 3.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input test $ 29-31 @;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; If test ne '' then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output bad;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input; /* to advance to next record*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Else do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Input&amp;nbsp; &amp;lt;your statements to read the data&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;any other statements&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;Output good;&lt;/STRONG&gt; /* need to explicitly write to the other set*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 May 2016 21:02:12 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-05-17T21:02:12Z</dc:date>
    <item>
      <title>reading from buffer</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271056#M58284</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;i have a&amp;nbsp; file that&amp;nbsp; i need to read in and&amp;nbsp; if data in the position 29-31 is not missing then stop or abort the process.&lt;/P&gt;
&lt;P&gt;The file has no headers so i am using the code below and after running it i dont see much happening in the logs and i have purposely put data in the position given above. Is this below right? Any one please&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;data _null_;&lt;BR /&gt;&amp;nbsp;infile file;&lt;BR /&gt;&amp;nbsp;input @;&lt;BR /&gt;&amp;nbsp;if substr(_infile_,29,31) ne'' then stop;&lt;BR /&gt;&amp;nbsp;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thx&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 20:15:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271056#M58284</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2016-05-17T20:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: reading form buffer</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271088#M58288</link>
      <description>&lt;P&gt;You will likely get unexpected results with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if substr(_infile_,29,31) ne'' then stop;&lt;/P&gt;
&lt;P&gt;As that substr says to start at position 29 and look at the next 31 positions&lt;/P&gt;
&lt;P&gt;You intended&lt;/P&gt;
&lt;P&gt;&amp;nbsp;if substr(_infile_,29,3) ne'' then stop;&lt;/P&gt;
&lt;P&gt;to read a length of 3 characters&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The log should tell you how many records were read. If there was something in the first line of the file then the log would show 1 record read. Assuming you had more lines in your file then the count would show the first line with something in that position. So since you say you made sure there was something in the first line then the program stops on the first line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, you could read that position directly:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input test 29-31 @;&lt;/P&gt;
&lt;P&gt;if test ne '' then stop&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 20:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271088#M58288</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-17T20:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: reading from buffer</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271111#M58291</link>
      <description>Thanks ballardw&lt;BR /&gt;Yes i meant 3 not 31. Thank you!&lt;BR /&gt;So i guess instead of aborting the process in such cases i can simply write the bad records to a dataset so in that case i will have access to those records. Right?</description>
      <pubDate>Tue, 17 May 2016 20:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271111#M58291</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2016-05-17T20:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: reading from buffer</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271114#M58293</link>
      <description>&lt;P&gt;Yes you could redirect the result to a different data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data good (drop= LongStr test)&amp;nbsp;bad (keep=LongStr);&amp;nbsp; /*&amp;lt;= TWO separate data sets that will have different variables*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Length LongStr $ 200; /*large enough to hold the longest expected _infile_ result*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; infile file;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; length test $ 3.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; input test $ 29-31 @;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; If test ne '' then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output bad;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;input; /* to advance to next record*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; Else do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Input&amp;nbsp; &amp;lt;your statements to read the data&amp;gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;any other statements&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;Output good;&lt;/STRONG&gt; /* need to explicitly write to the other set*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 21:02:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271114#M58293</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-17T21:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: reading from buffer</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271419#M58306</link>
      <description>&lt;P&gt;thanks a&amp;nbsp; lot!&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2016 14:31:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/reading-from-buffer/m-p/271419#M58306</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2016-05-18T14:31:19Z</dc:date>
    </item>
  </channel>
</rss>

