<?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 Text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461203#M117285</link>
    <description>&lt;P&gt;Why do you say that you tried my code?&amp;nbsp; I'm not using "=:".&amp;nbsp; I'm using INDEX instead.&amp;nbsp; In the third parameter of SCAN, you removed the blank between the quotes.&amp;nbsp; Put it back in and test again.&amp;nbsp; Better yet, copy/paste the code that I posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your code is now working, it is only because you are using cases where there is only one space between the ":" and the "2.9".&amp;nbsp; It won't work for a different number of spaces in between.&lt;/P&gt;</description>
    <pubDate>Wed, 09 May 2018 21:18:20 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-05-09T21:18:20Z</dc:date>
    <item>
      <title>Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460749#M117138</link>
      <description>&lt;P&gt;I have the following code used to find a line of text in a file:&lt;/P&gt;&lt;P&gt;%macro datm4;&lt;BR /&gt;%do i=1 %to 2;&lt;BR /&gt;data result&amp;amp;I ;&lt;BR /&gt;/*inialization of flag to 0 which will be used to find line of interest*/&lt;BR /&gt;retain flag_section1 0 ;&lt;BR /&gt;infile "/folders/myfolders/DLBOOTDAT_RIT/data/TEST&amp;amp;i..nm7/TEST&amp;amp;i..lst" END=EOF;&lt;BR /&gt;input @; if _infile_ =: 'NO. OF SIG. DIGITS IN FINAL EST.: 2.9' then flag_section1 =1;&lt;BR /&gt;&lt;BR /&gt;if eof then output;&lt;BR /&gt;run;&lt;BR /&gt;%END;&lt;BR /&gt;&lt;BR /&gt;TITLE ' DISTRIBUTION D DATA';&lt;BR /&gt;data FLAG;&lt;BR /&gt;set %do i=1 %to 2;RESULT&amp;amp;i %end ;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%mend datm4;&lt;BR /&gt;%datm4;&lt;/P&gt;&lt;P&gt;PROC PRINT DATA =RESULT1;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC PRINT DATA =RESULT2;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The *,lst file that I am searching has a line of text as follows:&amp;nbsp;&lt;/P&gt;&lt;P&gt;NO. OF SIG. DIGITS IN FINAL EST.:&amp;nbsp; 2.9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which I want to capture whenever the value is 2.9 at which time I want the&amp;nbsp;&lt;SPAN&gt;flag_section1 =1&lt;/SPAN&gt;.&amp;nbsp; However I am getting a value of zero irrespective of the value (.e. g., when the value is 2,7 or any other non 2.9 value).&amp;nbsp; Some of the prior lines in the file are listed below.&lt;/P&gt;&lt;P&gt;MINIMIZATION TERMINATED&lt;BR /&gt;&amp;nbsp;DUE TO ROUNDING ERRORS (ERROR=134)&lt;BR /&gt;&amp;nbsp;NO. OF FUNCTION EVALUATIONS USED:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 326&lt;BR /&gt;&amp;nbsp;NO. OF SIG. DIGITS IN FINAL EST.:&amp;nbsp; 2.9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone tell me why the flag_section is not seeing the number or suggest&amp;nbsp; other code that may be more effective?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 16:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460749#M117138</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2018-05-08T16:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460752#M117139</link>
      <description>&lt;P&gt;There may be more, but I see two issues right off the bat.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, what text are you searching for?&amp;nbsp; More specifically, how many spaces are there between the colon and the 2.9?&amp;nbsp; The actual message vs. your programming statement appear to be different in that regard.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, =: will include leading blanks when making the comparison.&amp;nbsp; You might switch to the INDEX function instead of using =:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 16:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460752#M117139</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-08T16:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460755#M117140</link>
      <description>This is the statement so the number of spaces may be two or three. How&lt;BR /&gt;should that be handled?&lt;BR /&gt;&lt;BR /&gt;NO. OF SIG. DIGITS IN FINAL EST.: 2.9&lt;BR /&gt;&lt;BR /&gt;Second, =: will include leading blanks when making the comparison. You&lt;BR /&gt;might switch to the INDEX function instead of using =:&lt;BR /&gt;&lt;BR /&gt;Are you referring to the flag_section1=1?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 May 2018 16:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460755#M117140</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2018-05-08T16:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460765#M117143</link>
      <description>&lt;P&gt;For both of my comments, I'm focusing on this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if _infile_ =: 'NO. OF SIG. DIGITS IN FINAL EST.: 2.9' then flag_section1 =1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given that there could be leading blanks within _INFILE_, and there could be a varying number of spaces following the colon, this might work to handle both issues:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if index(_infile_ , 'NO. OF SIG. DIGITS IN FINAL EST.:') and scan(_infile_, -1) = '2.9'&amp;nbsp;then flag_section1 =1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry I didn't come up with this earlier.&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 17:24:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460765#M117143</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-08T17:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460792#M117153</link>
      <description>I tried to play with the scan function by giving it a delimiter etc but it&lt;BR /&gt;kept returning 0. It is not finding the 2.9.&lt;BR /&gt;</description>
      <pubDate>Tue, 08 May 2018 18:44:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460792#M117153</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2018-05-08T18:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460793#M117154</link>
      <description>&lt;P&gt;Perhaps a different input:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;input @'NO. OF SIG. DIGITS IN FINAL EST.:' digits;
if digits=2.9 then flag_section1=1;&lt;/PRE&gt;
&lt;P&gt;which should read the value following the text using list input and ignores differing numbers of spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you actually have a number of flags to set based on different values of 2.9 or such then this is possibly a much more flexible solution&lt;/P&gt;</description>
      <pubDate>Tue, 08 May 2018 18:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/460793#M117154</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-05-08T18:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461032#M117223</link>
      <description>I tried this code and I also tried to edit it but no luck, it didn't work.&lt;BR /&gt;</description>
      <pubDate>Wed, 09 May 2018 14:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461032#M117223</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2018-05-09T14:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461136#M117263</link>
      <description>&lt;P&gt;Sorry, my fault here.&amp;nbsp; SCAN also uses a decimal point as one of its default delimiters.&amp;nbsp; For that part of the test, specify a blank as the only delimiter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and scan(_infile_, -1, ' ') = '2.9'&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 17:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461136#M117263</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-09T17:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461185#M117280</link>
      <description>When I tried your code&lt;BR /&gt;&lt;BR /&gt;if index(_infile_ , 'NO. OF SIG. DIGITS IN FINAL EST.:') and scan(_infile_,&lt;BR /&gt;-1,'') = '2.9' then flag_section1 =1, the file was not being read.&lt;BR /&gt;Therefore I combined your code with my original code:&lt;BR /&gt;&lt;BR /&gt;input @; if _infile_ =: 'NO. OF SIG. DIGITS IN FINAL EST.: 2.9' then&lt;BR /&gt;flag_section1 =1;&lt;BR /&gt;&lt;BR /&gt;When this was done I get the correct answer (see below) when I ran i=6 where&lt;BR /&gt;OBS 2 and 6 had the value =2.9.&lt;BR /&gt;&lt;BR /&gt;DISTRIBUTION D DATA&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Obs&lt;BR /&gt;&lt;BR /&gt;flag_section1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;&lt;BR /&gt;0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2&lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;3&lt;BR /&gt;&lt;BR /&gt;0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;4&lt;BR /&gt;&lt;BR /&gt;0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;5&lt;BR /&gt;&lt;BR /&gt;0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;6&lt;BR /&gt;&lt;BR /&gt;1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 09 May 2018 20:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461185#M117280</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2018-05-09T20:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461203#M117285</link>
      <description>&lt;P&gt;Why do you say that you tried my code?&amp;nbsp; I'm not using "=:".&amp;nbsp; I'm using INDEX instead.&amp;nbsp; In the third parameter of SCAN, you removed the blank between the quotes.&amp;nbsp; Put it back in and test again.&amp;nbsp; Better yet, copy/paste the code that I posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your code is now working, it is only because you are using cases where there is only one space between the ":" and the "2.9".&amp;nbsp; It won't work for a different number of spaces in between.&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 21:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461203#M117285</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-05-09T21:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461235#M117300</link>
      <description>There is a space between the ' '. This code works:&lt;BR /&gt;&lt;BR /&gt;%macro datm4;&lt;BR /&gt;&lt;BR /&gt;%do i=1 %to 210;&lt;BR /&gt;&lt;BR /&gt;data result&amp;amp;I ;&lt;BR /&gt;&lt;BR /&gt;/*inialization of flag to 0 which will be used to find line of interest*/&lt;BR /&gt;&lt;BR /&gt;retain flag_section1 0 ;&lt;BR /&gt;&lt;BR /&gt;infile "/folders/myfolders/DLBOOTDAT_RIT/data/TEST&amp;amp;i..nm7/TEST&amp;amp;i..lst"&lt;BR /&gt;END=EOF;&lt;BR /&gt;&lt;BR /&gt;if index(_infile_ , 'NO. OF SIG. DIGITS IN FINAL EST.:') and scan(_infile_,&lt;BR /&gt;-1,' ') = '2.9' then flag_section1 =1;&lt;BR /&gt;&lt;BR /&gt;input @; if _infile_ =: 'NO. OF SIG. DIGITS IN FINAL EST.: 2.9' then&lt;BR /&gt;flag_section1 =1;&lt;BR /&gt;&lt;BR /&gt;if eof then output;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%END;&lt;BR /&gt;&lt;BR /&gt;TITLE ' DISTRIBUTION D DATA';&lt;BR /&gt;&lt;BR /&gt;data FLAG;&lt;BR /&gt;&lt;BR /&gt;set %do i=1 %to 210;RESULT&amp;amp;i %end ;;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;%mend datm4;&lt;BR /&gt;&lt;BR /&gt;%datm4;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 10 May 2018 01:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461235#M117300</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2018-05-10T01:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461985#M117543</link>
      <description>&lt;P&gt;The code listed below works:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro datm4;&lt;BR /&gt;%do i=1 %to 210;&lt;BR /&gt;data result&amp;amp;I ;&lt;BR /&gt;/*inialization of flag to 0 which will be used to find line of interest*/&lt;BR /&gt;retain flag_section1 0 ;&lt;BR /&gt;infile "/folders/myfolders/DLBOOTDAT_RIT/data/TEST&amp;amp;i..nm7/TEST&amp;amp;i..lst" END=EOF;&lt;BR /&gt;if index(_infile_ , 'NO. OF SIG. DIGITS IN FINAL EST.:') and scan(_infile_, -1,'') = '2.9' then flag_section1 =1;&lt;/P&gt;&lt;P&gt;input @; if _infile_ =: 'NO. OF SIG. DIGITS IN FINAL EST.: 2.9' then flag_section1 =1;&lt;/P&gt;&lt;P&gt;if eof then output;&lt;BR /&gt;run;&lt;BR /&gt;%END;&lt;/P&gt;&lt;P&gt;TITLE ' DISTRIBUTION D DATA';&lt;BR /&gt;data FLAG;&lt;BR /&gt;set %do i=1 %to 210;RESULT&amp;amp;i %end ;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%mend datm4;&lt;BR /&gt;%datm4;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 11:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-Text/m-p/461985#M117543</guid>
      <dc:creator>jacksonan123</dc:creator>
      <dc:date>2018-05-14T11:30:44Z</dc:date>
    </item>
  </channel>
</rss>

