<?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: Comparing Numberic Values in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-Numberic-Values/m-p/75260#M21820</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I faced the same kind of issue and fixed it by forcing SAS to make the automatic conversion to a numeric variable.&lt;BR /&gt;
&lt;BR /&gt;
In your example, it becomes:&lt;BR /&gt;
&lt;BR /&gt;
if bal= put(((lagbal*-1)+lagbal2), best32.) then paid=0;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I don't know what really is the problem with SAS (we are still using the version &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; for such a situation and even don't know whether there is a fix to apply in order not having to implement such crappy solutions...&lt;BR /&gt;
&lt;BR /&gt;
Kind regards,&lt;BR /&gt;
Florent</description>
    <pubDate>Wed, 14 Apr 2010 17:50:47 GMT</pubDate>
    <dc:creator>Florent</dc:creator>
    <dc:date>2010-04-14T17:50:47Z</dc:date>
    <item>
      <title>Comparing Numberic Values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-Numberic-Values/m-p/75259#M21819</link>
      <description>I have an issue and have tried various ways of using the ROUND() function, but it's still not giving me what I need.&lt;BR /&gt;
&lt;BR /&gt;
Here is the example:&lt;BR /&gt;
&lt;BR /&gt;
bal            lagbal         lagbal2&lt;BR /&gt;
1119.16     -847.64       271.52&lt;BR /&gt;
&lt;BR /&gt;
The line in the program for the data above is:&lt;BR /&gt;
&lt;BR /&gt;
if bal=((lagbal*-1)+lagbal2) then paid=0&lt;BR /&gt;
&lt;BR /&gt;
if I change it to:&lt;BR /&gt;
if bal ne ((lagbal*-1)+lagbal2) then paid=0&lt;BR /&gt;
then it works&lt;BR /&gt;
&lt;BR /&gt;
When I compare the value of the bal and the expression (lagbal*-1)+lagbal2 then I get an exponential number. I have tried to round the variables, and it works for some but not all.  Any ideas on what I can do?</description>
      <pubDate>Wed, 14 Apr 2010 12:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-Numberic-Values/m-p/75259#M21819</guid>
      <dc:creator>redfishJAX</dc:creator>
      <dc:date>2010-04-14T12:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Numberic Values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-Numberic-Values/m-p/75260#M21820</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I faced the same kind of issue and fixed it by forcing SAS to make the automatic conversion to a numeric variable.&lt;BR /&gt;
&lt;BR /&gt;
In your example, it becomes:&lt;BR /&gt;
&lt;BR /&gt;
if bal= put(((lagbal*-1)+lagbal2), best32.) then paid=0;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I don't know what really is the problem with SAS (we are still using the version &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; for such a situation and even don't know whether there is a fix to apply in order not having to implement such crappy solutions...&lt;BR /&gt;
&lt;BR /&gt;
Kind regards,&lt;BR /&gt;
Florent</description>
      <pubDate>Wed, 14 Apr 2010 17:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-Numberic-Values/m-p/75260#M21820</guid>
      <dc:creator>Florent</dc:creator>
      <dc:date>2010-04-14T17:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Numberic Values</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-Numberic-Values/m-p/75261#M21821</link>
      <description>I'm not sure what you are trying to do, but I suspect that the problem is in &lt;BR /&gt;
&lt;BR /&gt;
lagbal*-1&lt;BR /&gt;
&lt;BR /&gt;
Because you didn't use parentheses, SAS has to make a guess about whether the minus sign is subtraction or an infix operator.  The multiplication can cause roundoff error (remember that the arithmetic is done in base-2) that makes the equal sign fail.&lt;BR /&gt;
&lt;BR /&gt;
Does it work if you re-write as&lt;BR /&gt;
&lt;BR /&gt;
IF bal=(labgal2 - lagbal) THEN paid=0;  ?&lt;BR /&gt;
&lt;BR /&gt;
Subtraction induces less roundoff error than multiplication.</description>
      <pubDate>Wed, 14 Apr 2010 18:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-Numberic-Values/m-p/75261#M21821</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-04-14T18:04:11Z</dc:date>
    </item>
  </channel>
</rss>

