<?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: if statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/if-statement/m-p/453097#M69857</link>
    <description>&lt;P&gt;You obviously have no clue what the macro facility is meant for.&lt;/P&gt;
&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do %until(min&amp;gt;=0.7);
if pe&amp;lt;0.7 &amp;amp; ps&amp;gt;=0.7 then
do; %let l=%eval(&amp;amp;l-1); %let m=&amp;amp;m; end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using macro statements this way can NEVER work. The %let statements are dealt with when the code for the data or proc step is fetched and compiled, so trying to execute them conditionally is nonsense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And a condition like that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do %until(min&amp;gt;=0.7);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can also never work, as the macro facility will compare the text "min" with the text "0.7", so min&amp;gt;=0.7 is always true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post your whole code, as what you have posted is missing lots of important items (like the procedure around the macro):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/204039"&gt;@shkim&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;%let k=6;&lt;BR /&gt;%let l=5;&lt;BR /&gt;%let m=1;&lt;/P&gt;
&lt;P&gt;%test(nb=5);&lt;/P&gt;
&lt;P&gt;%macro cccc;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do %until(min&amp;gt;=0.7);&lt;/P&gt;
&lt;P&gt;if pe&amp;lt;0.7 &amp;amp; ps&amp;gt;=0.7 then&lt;/P&gt;
&lt;P&gt;do; %let l=%eval(&amp;amp;l-1); %let m=&amp;amp;m; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if ps&amp;lt;0.7 &amp;amp; pe&amp;gt;=0.7 then&lt;/P&gt;
&lt;P&gt;do; %let m=%eval(&amp;amp;m+1);%let l=&amp;amp;l; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if pe&amp;lt;0.7 &amp;amp; pe&amp;lt;0.7 then do;&amp;nbsp;&lt;BR /&gt;%let l=%eval(&amp;amp;l-1);&lt;BR /&gt;%let m=%eval(&amp;amp;m+1); end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%test(nb=5);&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;med[1,1]=%eval(&amp;amp;l+1);&lt;BR /&gt;msd[1,1]=%eval(&amp;amp;m-1);&lt;BR /&gt;print med msd; print &amp;amp;l &amp;amp;m;&lt;/P&gt;
&lt;P&gt;%mend;&lt;BR /&gt;%cccc;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have the problem of ignoring conditional execution and executing all three cases.&lt;BR /&gt;what should i do?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Apr 2018 08:20:07 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-04-11T08:20:07Z</dc:date>
    <item>
      <title>if statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/if-statement/m-p/453041#M69854</link>
      <description>&lt;P&gt;&lt;BR /&gt;%let k=6;&lt;BR /&gt;%let l=5;&lt;BR /&gt;%let m=1;&lt;/P&gt;&lt;P&gt;%test(nb=5);&lt;/P&gt;&lt;P&gt;%macro cccc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%do %until(min&amp;gt;=0.7);&lt;/P&gt;&lt;P&gt;if pe&amp;lt;0.7 &amp;amp; ps&amp;gt;=0.7 then&lt;/P&gt;&lt;P&gt;do; %let l=%eval(&amp;amp;l-1); %let m=&amp;amp;m; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if ps&amp;lt;0.7 &amp;amp; pe&amp;gt;=0.7 then&lt;/P&gt;&lt;P&gt;do; %let m=%eval(&amp;amp;m+1);%let l=&amp;amp;l; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if pe&amp;lt;0.7 &amp;amp; pe&amp;lt;0.7 then do;&amp;nbsp;&lt;BR /&gt;%let l=%eval(&amp;amp;l-1);&lt;BR /&gt;%let m=%eval(&amp;amp;m+1); end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%test(nb=5);&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;med[1,1]=%eval(&amp;amp;l+1);&lt;BR /&gt;msd[1,1]=%eval(&amp;amp;m-1);&lt;BR /&gt;print med msd; print &amp;amp;l &amp;amp;m;&lt;/P&gt;&lt;P&gt;%mend;&lt;BR /&gt;%cccc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have the problem of ignoring conditional execution and executing all three cases.&lt;BR /&gt;what should i do?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 03:08:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/if-statement/m-p/453041#M69854</guid>
      <dc:creator>shkim</dc:creator>
      <dc:date>2018-04-11T03:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: if statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/if-statement/m-p/453090#M69856</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should you use macro statements i.e. with % sign:&lt;/P&gt;&lt;P&gt;%if %then %do %end&lt;/P&gt;&lt;P&gt;...?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 07:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/if-statement/m-p/453090#M69856</guid>
      <dc:creator>FloT</dc:creator>
      <dc:date>2018-04-11T07:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: if statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/if-statement/m-p/453097#M69857</link>
      <description>&lt;P&gt;You obviously have no clue what the macro facility is meant for.&lt;/P&gt;
&lt;P&gt;See this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do %until(min&amp;gt;=0.7);
if pe&amp;lt;0.7 &amp;amp; ps&amp;gt;=0.7 then
do; %let l=%eval(&amp;amp;l-1); %let m=&amp;amp;m; end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Using macro statements this way can NEVER work. The %let statements are dealt with when the code for the data or proc step is fetched and compiled, so trying to execute them conditionally is nonsense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And a condition like that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do %until(min&amp;gt;=0.7);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;can also never work, as the macro facility will compare the text "min" with the text "0.7", so min&amp;gt;=0.7 is always true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post your whole code, as what you have posted is missing lots of important items (like the procedure around the macro):&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/204039"&gt;@shkim&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;%let k=6;&lt;BR /&gt;%let l=5;&lt;BR /&gt;%let m=1;&lt;/P&gt;
&lt;P&gt;%test(nb=5);&lt;/P&gt;
&lt;P&gt;%macro cccc;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do %until(min&amp;gt;=0.7);&lt;/P&gt;
&lt;P&gt;if pe&amp;lt;0.7 &amp;amp; ps&amp;gt;=0.7 then&lt;/P&gt;
&lt;P&gt;do; %let l=%eval(&amp;amp;l-1); %let m=&amp;amp;m; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if ps&amp;lt;0.7 &amp;amp; pe&amp;gt;=0.7 then&lt;/P&gt;
&lt;P&gt;do; %let m=%eval(&amp;amp;m+1);%let l=&amp;amp;l; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if pe&amp;lt;0.7 &amp;amp; pe&amp;lt;0.7 then do;&amp;nbsp;&lt;BR /&gt;%let l=%eval(&amp;amp;l-1);&lt;BR /&gt;%let m=%eval(&amp;amp;m+1); end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%test(nb=5);&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;med[1,1]=%eval(&amp;amp;l+1);&lt;BR /&gt;msd[1,1]=%eval(&amp;amp;m-1);&lt;BR /&gt;print med msd; print &amp;amp;l &amp;amp;m;&lt;/P&gt;
&lt;P&gt;%mend;&lt;BR /&gt;%cccc;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have the problem of ignoring conditional execution and executing all three cases.&lt;BR /&gt;what should i do?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 08:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/if-statement/m-p/453097#M69857</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-11T08:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: if statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/if-statement/m-p/453117#M69859</link>
      <description>&lt;P&gt;ex data)&lt;/P&gt;&lt;P&gt;proc iml;&lt;BR /&gt;ze_0={1,2,3};&lt;BR /&gt;zs_0{1,3,5};&lt;BR /&gt;ze_1={2,3,4};&lt;BR /&gt;zs_1={2,4,2};&lt;BR /&gt;ze_2={1,3,2};&lt;BR /&gt;zs_2={2,5,4};&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;pe=#{max(ze_i[&amp;amp;l,1],zs_i[&amp;amp;m,1])&amp;gt;=ze_0[&amp;amp;l,1]}/nb&lt;BR /&gt;ps=#{max(zs_i[&amp;amp;l,1],zs_i[&amp;amp;m,1])&amp;gt;=zs_0[&amp;amp;m,1]}/nb&lt;/P&gt;&lt;P&gt;i=1,2&lt;BR /&gt;nb=2&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have already&amp;nbsp;complete macro program code that computes pe and ps. (%test)&lt;BR /&gt;but, i don't know how to code this part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="short_text"&gt;&lt;SPAN&gt;Initial value&lt;/SPAN&gt;&lt;/SPAN&gt; l=3 , m=1&lt;/P&gt;&lt;P&gt;if pe &amp;lt; 0.05 then&amp;nbsp;I = l-1, If ps &amp;lt; 0.05 then&amp;nbsp;m = m + 1,&lt;/P&gt;&lt;P&gt;and pe and ps must be repeated until both are greater than 0.05.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Apr 2018 09:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/if-statement/m-p/453117#M69859</guid>
      <dc:creator>shkim</dc:creator>
      <dc:date>2018-04-11T09:24:13Z</dc:date>
    </item>
  </channel>
</rss>

