<?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: ERROR: The %IF statement is not valid in open code. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685354#M207848</link>
    <description>&lt;P&gt;Please verify that you are using at least 9.4m5.&lt;/P&gt;</description>
    <pubDate>Mon, 21 Sep 2020 09:54:55 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2020-09-21T09:54:55Z</dc:date>
    <item>
      <title>ERROR: The %IF statement is not valid in open code.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685316#M207836</link>
      <description>&lt;P&gt;hi, i am running the below user written code in SAS DI job and i am getting error please suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Email_Address=;
proc sql noprint;
select distinct cat('"',strip(Email_Address),'"')
into :Email_Address
separated by ' '
from yyyyy
;
quit;
%if %eval(&amp;amp;syscc &amp;gt; 0) %then %return;
%put Email_Address = &amp;amp;Email_Address;
%macro send_email;
%if &amp;amp;Email_Address ne %then %do;
filename email email
from=('xxxxxxx.com')
sender=('xxxxxxx.com')
to=(&amp;amp;Email_Address)
cc=('rrrrrrr.com' 'xxxxxxx.com' 'CCCCCC.com')
subject=('cccccccccccccccccccccccc')
importance='high'
type='text/html'
CT ='text/html'
;
title;
ods html body=email;
ods html text='Hello';
ods html text=' ';
ods html text='gggggggggggggggggggggggggggggggggggg';
ods html text=' ';
ods html text='uyuuuuuuuuuuuuuuuuuuuu.';
ods html text=' ';
ods html text='ccccccccccccccccccccccccccccc xxxxxxx.com .';
ods html text=' ';
ods html text='iiiiiiiiiiiiiiiiiiiiiiiiiiiiiit';
ods html text=' ';
proc print data=output1 label noobs;quit;
%if %eval(&amp;amp;syscc &amp;gt; 0) %then %return;
ods html text=' ';
ods html text='Thanks';
ods html text='XXXXXXXXXXXXXXX';
ods html text='Email: xxxxxxx.com';
ods _all_ close;
%end;
%mend;
%send_email;



&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JJP1_0-1600670267153.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49572iA9322A26F4DFD72D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JJP1_0-1600670267153.png" alt="JJP1_0-1600670267153.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 06:40:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685316#M207836</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2020-09-21T06:40:22Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: The %IF statement is not valid in open code.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685317#M207837</link>
      <description>&lt;P&gt;Since SAS 9.4M5, you can use %IF-%THEN-%DO-%END in open code, but not %IF-%THEN without the %DO-%END.&lt;/P&gt;
&lt;P&gt;Expand this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %eval(&amp;amp;syscc &amp;gt; 0) %then %return;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %eval(&amp;amp;syscc &amp;gt; 0) %then %do; %return; %end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Sep 2020 06:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685317#M207837</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-21T06:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: The %IF statement is not valid in open code.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685349#M207846</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;but iam still getting error after expanding the code as you suggested. would you pleas correct me&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JJP1_0-1600680443269.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/49588i2545E7ED7B6EA230/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JJP1_0-1600680443269.png" alt="JJP1_0-1600680443269.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 09:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685349#M207846</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2020-09-21T09:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: The %IF statement is not valid in open code.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685354#M207848</link>
      <description>&lt;P&gt;Please verify that you are using at least 9.4m5.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 09:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685354#M207848</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-09-21T09:54:55Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: The %IF statement is not valid in open code.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685363#M207853</link>
      <description>&lt;P&gt;I am using SAS DI 4.4 application please&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 10:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685363#M207853</guid>
      <dc:creator>JJP1</dc:creator>
      <dc:date>2020-09-21T10:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: The %IF statement is not valid in open code.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685373#M207859</link>
      <description>&lt;P&gt;We need to know the backend SAS version, not the version of the frontend. Run this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;sysvlong;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc setinit;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and look at the log.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 11:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685373#M207859</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-21T11:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: The %IF statement is not valid in open code.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685377#M207862</link>
      <description>&lt;P&gt;Just a few notes about things you willl need to clean up sooner or later ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, don't define %SEND_EMAIL inside an %IF %THEN condition.&amp;nbsp; Pull out the definition of the macro so it stands alone.&amp;nbsp; The other logic can still call %SEND_EMAIL.&amp;nbsp; That will make your logic easier to understand and debug.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, what is the first %RETURN statement supposed to do?&amp;nbsp; Even if you solve for %IF in open code, there is no way to make a %RETURN statement valid outside of a macro definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, beware of this comparison:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;Email_Address ne %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Some email addresses contain a dash.&amp;nbsp; If that occurs, macro language will interpret that as subtraction and give you an error message.&amp;nbsp; Safer:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %length(&amp;amp;Email_Address) %then %do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 11:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-The-IF-statement-is-not-valid-in-open-code/m-p/685377#M207862</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-09-21T11:17:02Z</dc:date>
    </item>
  </channel>
</rss>

