<?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: multiple operators in %if macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864202#M341301</link>
    <description>&lt;P&gt;the original macro program showed below:&lt;/P&gt;&lt;P&gt;%macro compare_brand(brand);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; %if &amp;amp;brand = GE %then %put Brand is General Electric;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%else %put Brand is &amp;amp;brand;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%mend;&lt;BR /&gt;%compare_brand(Coke)&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2023 03:44:41 GMT</pubDate>
    <dc:creator>Alexx_</dc:creator>
    <dc:date>2023-03-15T03:44:41Z</dc:date>
    <item>
      <title>multiple operators in %if macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864197#M341296</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am learning a macro program. I am confused about multiple operators. I don't know how SAS evaluates&amp;nbsp;%if comparisons with two&amp;nbsp;operators, one is "(&amp;amp;brand. = Flase)", the other is "&amp;gt;=.". the result of this program returned&amp;nbsp; "Brand is General Electric". may I know why? how to&amp;nbsp;&lt;SPAN&gt;decompose multiple operators?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;%macro corpare_brand(brand);&lt;BR /&gt;%if ((&amp;amp;brand. &lt;FONT color="#FF0000"&gt;=&lt;/FONT&gt; Flase) &lt;FONT color="#FF0000"&gt;&amp;gt;=&lt;/FONT&gt;. ) %then %put Brand is General Electric;&lt;BR /&gt;%else %put Brand is &amp;amp;brand;&lt;BR /&gt;%mend;&lt;BR /&gt;%corpare_brand(Coke)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 03:19:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864197#M341296</guid>
      <dc:creator>Alexx_</dc:creator>
      <dc:date>2023-03-15T03:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: multiple operators in %if macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864199#M341298</link>
      <description>&lt;P&gt;If you are just testing equality this works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro corpare_brand(brand);
%if &amp;amp;brand. = Flase %then %put Brand is General Electric;
%else %put Brand is &amp;amp;brand;
%mend;
%corpare_brand(Coke);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Mar 2023 03:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864199#M341298</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-03-15T03:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: multiple operators in %if macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864200#M341299</link>
      <description>yes, I know that works. but "%if &amp;amp;brand. = Flase" returned "Brand is Coke". But I want to know why "%if ((&amp;amp;brand. = Flase) &amp;gt;=. )" returned "Brand is General Electric"</description>
      <pubDate>Wed, 15 Mar 2023 03:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864200#M341299</guid>
      <dc:creator>Alexx_</dc:creator>
      <dc:date>2023-03-15T03:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: multiple operators in %if macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864202#M341301</link>
      <description>&lt;P&gt;the original macro program showed below:&lt;/P&gt;&lt;P&gt;%macro compare_brand(brand);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; %if &amp;amp;brand = GE %then %put Brand is General Electric;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%else %put Brand is &amp;amp;brand;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%mend;&lt;BR /&gt;%compare_brand(Coke)&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 03:44:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864202#M341301</guid>
      <dc:creator>Alexx_</dc:creator>
      <dc:date>2023-03-15T03:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: multiple operators in %if macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864205#M341303</link>
      <description>&lt;P&gt;What are you trying to do with this -"%if ((&amp;amp;brand. = Flase) &amp;gt;=. )" ? Some sort of Boolean comparison?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 03:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864205#M341303</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-03-15T03:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: multiple operators in %if macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864209#M341304</link>
      <description>&lt;P&gt;SAS uses %EVAL() to evaluate the condition in a %IF statement.&lt;/P&gt;
&lt;P&gt;So just ask %EVAL() what it thinks of those tests.&lt;/P&gt;
&lt;PRE&gt;1009  %put %eval( Coke = Flase );
0
1010  %put %eval(0 &amp;gt;= .);
1
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the test:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if ((&amp;amp;brand. = Flase) &amp;gt;=. ) %then &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is always TRUE.&lt;/P&gt;
&lt;P&gt;Do you see why?&lt;/P&gt;
&lt;LI-SPOILER&gt;The result of a boolean expression is either TRUE (1) or FALSE (0).&amp;nbsp; &lt;BR /&gt;&lt;BR /&gt;If %EVAL() decided to compare them as numbers then both 0 and 1 are larger than a missing value .&lt;BR /&gt;&lt;BR /&gt;And if %EVAL() decided to do a character comparison both '30'x and '31'x are greater than '2E'x.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 04:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864209#M341304</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-15T04:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: multiple operators in %if macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864223#M341317</link>
      <description>This statement doesn't compare anything to the string GE.  In macro language, GE means "greater than or equal to".  &lt;BR /&gt;&lt;BR /&gt;The easiest workaround would be to add double quotes to the comparison:&lt;BR /&gt;&lt;BR /&gt;%if "&amp;amp;brand" = "GE" %then %put Brand is General Electric;</description>
      <pubDate>Wed, 15 Mar 2023 07:58:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864223#M341317</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-03-15T07:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: multiple operators in %if macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864355#M341354</link>
      <description>thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;</description>
      <pubDate>Wed, 15 Mar 2023 15:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/multiple-operators-in-if-macro/m-p/864355#M341354</guid>
      <dc:creator>Alexx_</dc:creator>
      <dc:date>2023-03-15T15:58:27Z</dc:date>
    </item>
  </channel>
</rss>

