<?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: Infile and Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349867#M81256</link>
    <description>&lt;P&gt;You don't have a data statement before the infile. Might be other issues, but that's critical.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Apr 2017 20:02:29 GMT</pubDate>
    <dc:creator>collinelliot</dc:creator>
    <dc:date>2017-04-13T20:02:29Z</dc:date>
    <item>
      <title>Infile and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349865#M81254</link>
      <description>&lt;P&gt;In macro I am trying to read a string from a file and then send email if it exists.I am using the below code for that and getting few errors.Can someone help me to fix the errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &lt;STRONG&gt;&lt;I&gt;FileProcess&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Infile &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'C:\Users\FSAX.txt'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; truncover;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;input a_line &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$200.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(a_line, &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'ERROR:'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &amp;gt; &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Message = "Hello";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;Email&lt;/I&gt;&lt;/STRONG&gt;();&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;%Mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;FileProcess&lt;/I&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "FILEPROCESS".&lt;/P&gt;&lt;P&gt;1 Infile 'C:\Users\FSAX.txt' truncover;&lt;/P&gt;&lt;P&gt;------&lt;/P&gt;&lt;P&gt;180&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the invoked macro "FILEPROCESS".&lt;/P&gt;&lt;P&gt;1 input a_line $200.;&lt;/P&gt;&lt;P&gt;-----&lt;/P&gt;&lt;P&gt;180&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;ERROR: Required operator not found in expression: index(a_line, 'ERROR:') &amp;gt; 0&lt;/P&gt;&lt;P&gt;ERROR: The macro FILEPROCESS will stop executing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 19:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349865#M81254</guid>
      <dc:creator>Melvin_Sas</dc:creator>
      <dc:date>2017-04-13T19:56:24Z</dc:date>
    </item>
    <item>
      <title>Re: Infile and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349867#M81256</link>
      <description>&lt;P&gt;You don't have a data statement before the infile. Might be other issues, but that's critical.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 20:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349867#M81256</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-13T20:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Infile and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349868#M81257</link>
      <description>&lt;PRE&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;CODE class=" language-sas"&gt;%if index(a_line, 'ERROR:') &amp;gt; 0 %then %do;
%Let Message = "Hello";
&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;These two statements should not be macro statements, and will not work as macro statements. You need&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="Courier New" size="2"&gt;if index(a_line, 'ERROR:') &amp;gt; 0 then do;
message = 'Hello';
end;
&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;As stated by the other respondent, you also need a DATA statement for any of this to work.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 20:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349868#M81257</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-04-13T20:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Infile and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349869#M81258</link>
      <description>&lt;P&gt;Thanks.. added the datastep but still getting the below error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2939 %global Message;&lt;/P&gt;&lt;P&gt;2940 %macro FileProcess;&lt;/P&gt;&lt;P&gt;2941 data _null_;&lt;/P&gt;&lt;P&gt;2942 Infile 'C:\Users\FSAX.txt' truncover;&lt;/P&gt;&lt;P&gt;2943 input a_line $2000.;&lt;/P&gt;&lt;P&gt;2944 %if index(a_line, 'ERROR:') &amp;gt; 0 %then %do;&lt;/P&gt;&lt;P&gt;2945 %Let Message = "Hello";&lt;/P&gt;&lt;P&gt;2946 %Email();&lt;/P&gt;&lt;P&gt;2947 %end;&lt;/P&gt;&lt;P&gt;2948&lt;/P&gt;&lt;P&gt;2949 %Mend;&lt;/P&gt;&lt;P&gt;2950&lt;/P&gt;&lt;P&gt;2951 %FileProcess;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 12.67 seconds&lt;/P&gt;&lt;P&gt;cpu time 1.24 seconds&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;ERROR: Required operator not found in expression: index(a_line, 'ERROR:') &amp;gt; 0&lt;/P&gt;&lt;P&gt;ERROR: The macro FILEPROCESS will stop executing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 20:09:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349869#M81258</guid>
      <dc:creator>Melvin_Sas</dc:creator>
      <dc:date>2017-04-13T20:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Infile and Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349870#M81259</link>
      <description>&lt;P&gt;Ok thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2017 20:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-and-Macro/m-p/349870#M81259</guid>
      <dc:creator>Melvin_Sas</dc:creator>
      <dc:date>2017-04-13T20:13:52Z</dc:date>
    </item>
  </channel>
</rss>

