<?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: question related to LE operator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321345#M70934</link>
    <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote: It's about rounding and how computers store values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run below code and have a look at the "data two"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input a b;
  datalines;
12.45 12.40
13.55 13.50
17.50 17.45
14.70 14.76
15.47 15.50
;
run;

data two;
  set one;
  format diff1 diff2 best32.;
  diff1= abs(b-a);
  diff2=round(diff1,0.000001);
  if round(abs(b-a),0.0000001) le 0.05 then
    result='success';
  else result='failure';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's not so that SAS does something wrong but it is a common trap and I'd wish for some system option which would allow us to define a max.&amp;nbsp;precision so that rounding happens implicitely.&lt;/P&gt;</description>
    <pubDate>Tue, 27 Dec 2016 21:23:23 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2016-12-27T21:23:23Z</dc:date>
    <item>
      <title>question related to LE operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321325#M70925</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to run the below code.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; one;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a b;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;12.45 12.40&lt;/P&gt;
&lt;P&gt;13.55 13.50&lt;/P&gt;
&lt;P&gt;17.50 17.45&lt;/P&gt;
&lt;P&gt;14.70 14.76&lt;/P&gt;
&lt;P&gt;15.47 15.50&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; two;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; one;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;diff1= abs(b-a);&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; abs(b-a) le &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0.05&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; result=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'success'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;else&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; result=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'failure'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;The second and third row has&amp;nbsp; diff1 equal to 0.05 but the result is getting value failure. First row is getting values appropriately.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Appreciate any help.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Sheeba&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 19:28:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321325#M70925</guid>
      <dc:creator>Sheeba</dc:creator>
      <dc:date>2016-12-27T19:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: question related to LE operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321339#M70929</link>
      <description>&lt;P&gt;Round the numbers before you do a calculation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Numbers cannot be stored exactly so the number is likely 0.050000001 or something like that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p0ji1unv6thm0dn1gp4t01a1u0g6.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/69852/HTML/default/viewer.htm#p0ji1unv6thm0dn1gp4t01a1u0g6.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 20:56:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321339#M70929</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-27T20:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: question related to LE operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321345#M70934</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote: It's about rounding and how computers store values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run below code and have a look at the "data two"&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input a b;
  datalines;
12.45 12.40
13.55 13.50
17.50 17.45
14.70 14.76
15.47 15.50
;
run;

data two;
  set one;
  format diff1 diff2 best32.;
  diff1= abs(b-a);
  diff2=round(diff1,0.000001);
  if round(abs(b-a),0.0000001) le 0.05 then
    result='success';
  else result='failure';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's not so that SAS does something wrong but it is a common trap and I'd wish for some system option which would allow us to define a max.&amp;nbsp;precision so that rounding happens implicitely.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2016 21:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321345#M70934</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-12-27T21:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: question related to LE operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321400#M70959</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I totally agree with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; ' s proposal about the rounding . I have met many people working with SAS failing to deal properly with number calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I may&amp;nbsp; , I would add a note in the log specifying the implicit rounding (when it takes place).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; could you open a topic so the community votes for this proposal ?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 08:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321400#M70959</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-12-28T08:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: question related to LE operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321451#M70988</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks a lot for the details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is working as expected now&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sheeba&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 17:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321451#M70988</guid>
      <dc:creator>Sheeba</dc:creator>
      <dc:date>2016-12-28T17:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: question related to LE operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321452#M70989</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for helping me out. With rounding the issue is resolved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The option to define a max precision will be nice to have in such cases .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again,&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sheeba&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 18:00:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321452#M70989</guid>
      <dc:creator>Sheeba</dc:creator>
      <dc:date>2016-12-28T18:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: question related to LE operator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321453#M70990</link>
      <description>&lt;P&gt;Hi Loko,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reply. Yes rounding resolved the issue here&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Sheeba&lt;/P&gt;</description>
      <pubDate>Wed, 28 Dec 2016 18:02:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/question-related-to-LE-operator/m-p/321453#M70990</guid>
      <dc:creator>Sheeba</dc:creator>
      <dc:date>2016-12-28T18:02:02Z</dc:date>
    </item>
  </channel>
</rss>

