<?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 Macro Not Working in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487392#M127002</link>
    <description>thanks!</description>
    <pubDate>Thu, 16 Aug 2018 13:00:26 GMT</pubDate>
    <dc:creator>BrentonCSmith</dc:creator>
    <dc:date>2018-08-16T13:00:26Z</dc:date>
    <item>
      <title>%IF Macro Not Working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487255#M126941</link>
      <description>&lt;P&gt;My %IF macro is not working.&amp;nbsp; .1 should be &amp;gt; 0 but in this macro it executes the %ELSE conditional.&amp;nbsp; If I Enter 1, the %IF condition is excuted.&amp;nbsp; The problem is that .1&amp;nbsp; is GT 0.&amp;nbsp; It if late, but the message "%IF condition .1 &amp;gt; 0 is FALSE" doesn't make sense to these tired eyes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro ApplyTax(Tax,TRate,AnnualBenefit);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %if .1&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt; 0 %then put "Is Greater";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else put "is less than";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; %if &amp;amp;TRate&amp;gt; 0 %then put "Is Greater";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else put "is less than";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;Data DS;&lt;BR /&gt;&amp;nbsp; %ApplyTax(dsvar,.1,1000);&lt;BR /&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the MPRINT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;151 Data DS;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;152 %ApplyTax(dsvar,.1,1000);&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MLOGIC(APPLYTAX): Beginning execution.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MLOGIC(APPLYTAX): Parameter TAX has value dsvar&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MLOGIC(APPLYTAX): Parameter TRATE has value .1&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MLOGIC(APPLYTAX): Parameter ANNUALBENEFIT has value 1000&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&lt;STRONG&gt;MLOGIC(APPLYTAX): %IF condition .1 &amp;gt; 0 is FALSE&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MPRINT(APPLYTAX): put "is less than" ;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&lt;STRONG&gt;SYMBOLGEN: Macro variable TRATE resolves to .1&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&lt;STRONG&gt;MLOGIC(APPLYTAX): %IF condition &amp;amp;TRate&amp;gt; 0 is FALSE&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MPRINT(APPLYTAX): put "is less than" ;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;MLOGIC(APPLYTAX): Ending execution.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;153 run;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;PRE class="sasLog"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 04:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487255#M126941</guid>
      <dc:creator>BrentonCSmith</dc:creator>
      <dc:date>2018-08-16T04:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: %IF Macro Not Working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487257#M126943</link>
      <description>&lt;P&gt;It is doing what you asked it to do. The ASCII code for a period is less than the code for the zero character.&lt;/P&gt;
&lt;PRE&gt;2    data _null_;
3      a='.1';
4      b='0';
5      put (a b) (= $hex.);
6    run;

a=2E31 b=30
&lt;/PRE&gt;
&lt;P&gt;If you want to try to compare floating point values in macro code you need to use %SYSEVALF()&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysevalf( .1 &amp;gt; 0) ...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 04:47:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487257#M126943</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-08-16T04:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: %IF Macro Not Working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487300#M126957</link>
      <description>&lt;P&gt;Automatic arithmetic evaluation in a %if condition will only be done when integers are used. In all other cases, you need to assist the macro compiler as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; suggested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(this works as intended)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if 23 &amp;gt; 3 %then %do; %put yes; %end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Aug 2018 07:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487300#M126957</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-16T07:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: %IF Macro Not Working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487318#M126968</link>
      <description>&lt;P&gt;&lt;SPAN&gt;"If you want to try to compare floating point values" -&amp;nbsp;Or of course, do data processing in datastep where it belongs, where the data types are present for such data and where functions are there to perform such processing.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 08:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487318#M126968</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-16T08:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: %IF Macro Not Working</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487392#M127002</link>
      <description>thanks!</description>
      <pubDate>Thu, 16 Aug 2018 13:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-Macro-Not-Working/m-p/487392#M127002</guid>
      <dc:creator>BrentonCSmith</dc:creator>
      <dc:date>2018-08-16T13:00:26Z</dc:date>
    </item>
  </channel>
</rss>

