<?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 Comparison between two values are Giving wrong results in %If in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190424#M48033</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;I am writing the below %If else statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;%if (%sysfunc(abs(%sysevalf((47496-49030.8)/49030.8)*100)) gt 12)then %do; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;%Put I am in the Loop; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;%End;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In log it is showing that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MLOGIC(S1): %IF condition&lt;BR /&gt;(%sysfunc(abs(%sysevalf((47496-49030.8)/49030.8)*100)) gt 12)&lt;BR /&gt;is TRUE &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whereas if I check the value of the calculation in the below chunk:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let a= %sysfunc(abs(%sysevalf((47496-49030.8)/49030.8)*100));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%Put &amp;amp;a.;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Then in the Log it is showing:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;S&lt;/SPAN&gt;YMBOLGEN: Macro variable A resolves&lt;BR /&gt;to 3.130277295087 &lt;BR /&gt;3.130277295087&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, now my question is how can 3.130277295087 be greater than 12?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe this has to do something with how SAS stores the data internally in hexadecimal form. But I am not very sure. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody shed some light on this one?&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; If I put a round function in the %If statement, then the result comes out as expected (i.e.False).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks all in advance for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Regards,&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Saugata Mukherjee.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Apr 2014 07:06:44 GMT</pubDate>
    <dc:creator>Saugata</dc:creator>
    <dc:date>2014-04-23T07:06:44Z</dc:date>
    <item>
      <title>Comparison between two values are Giving wrong results in %If</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190424#M48033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;I am writing the below %If else statement:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;%if (%sysfunc(abs(%sysevalf((47496-49030.8)/49030.8)*100)) gt 12)then %do; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;%Put I am in the Loop; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG&gt;%End;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In log it is showing that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MLOGIC(S1): %IF condition&lt;BR /&gt;(%sysfunc(abs(%sysevalf((47496-49030.8)/49030.8)*100)) gt 12)&lt;BR /&gt;is TRUE &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whereas if I check the value of the calculation in the below chunk:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let a= %sysfunc(abs(%sysevalf((47496-49030.8)/49030.8)*100));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%Put &amp;amp;a.;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Then in the Log it is showing:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;S&lt;/SPAN&gt;YMBOLGEN: Macro variable A resolves&lt;BR /&gt;to 3.130277295087 &lt;BR /&gt;3.130277295087&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, now my question is how can 3.130277295087 be greater than 12?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I believe this has to do something with how SAS stores the data internally in hexadecimal form. But I am not very sure. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody shed some light on this one?&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt; If I put a round function in the %If statement, then the result comes out as expected (i.e.False).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks all in advance for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Regards,&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Saugata Mukherjee.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 07:06:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190424#M48033</guid>
      <dc:creator>Saugata</dc:creator>
      <dc:date>2014-04-23T07:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison between two values are Giving wrong results in %If</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190425#M48034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Without the round function, you have a period in the number, which causes the macro processor to treat the numbers as character strings and do a string comparison, which yields the undesired result.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the documentation of the %sysevalf function, which will help here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 08:36:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190425#M48034</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-04-23T08:36:44Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison between two values are Giving wrong results in %If</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190426#M48035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, does that mean that it is not possible to do floating point comparison in %If statement?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Regards,&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;Saugata Mukherjee.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 09:57:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190426#M48035</guid>
      <dc:creator>Saugata</dc:creator>
      <dc:date>2014-04-23T09:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison between two values are Giving wrong results in %If</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190427#M48036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have a look at this:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001072297.htm" title="http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001072297.htm"&gt;SAS(R) 9.2 Macro Language: Reference&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Right in the middle you have an example of how the %sysevalf function makes it possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 10:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190427#M48036</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-04-23T10:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison between two values are Giving wrong results in %If</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190428#M48037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if %sysevalf((%sysfunc(abs(%sysevalf((47496-49030.8)/49030.8)*100))) gt 12) %then %do; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %Put I am in the Loop; &lt;BR /&gt;%End;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 11:09:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190428#M48037</guid>
      <dc:creator>SKK</dc:creator>
      <dc:date>2014-04-23T11:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison between two values are Giving wrong results in %If</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190429#M48038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Kurt. Now I have a better understanding of this :smileylaugh:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 11:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190429#M48038</guid>
      <dc:creator>Saugata</dc:creator>
      <dc:date>2014-04-23T11:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison between two values are Giving wrong results in %If</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190430#M48039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 11:59:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparison-between-two-values-are-Giving-wrong-results-in-If/m-p/190430#M48039</guid>
      <dc:creator>Saugata</dc:creator>
      <dc:date>2014-04-23T11:59:30Z</dc:date>
    </item>
  </channel>
</rss>

