<?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 Apparent SAS calculation error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apparent-SAS-calculation-error/m-p/720202#M223077</link>
    <description>&lt;P&gt;Consider the following code.&amp;nbsp; a = b and yet SAS determines that a &amp;lt; b.&amp;nbsp; Why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data x;&lt;BR /&gt;a = 11*10;&lt;BR /&gt;b = (11/10)*100;&lt;BR /&gt;if a = b then put 'equal';&lt;BR /&gt;if a &amp;gt; b then put 'greater';&lt;BR /&gt;if a &amp;lt; b then put 'less';&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Feb 2021 15:02:21 GMT</pubDate>
    <dc:creator>SAS1ns1ghts</dc:creator>
    <dc:date>2021-02-18T15:02:21Z</dc:date>
    <item>
      <title>Apparent SAS calculation error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-SAS-calculation-error/m-p/720202#M223077</link>
      <description>&lt;P&gt;Consider the following code.&amp;nbsp; a = b and yet SAS determines that a &amp;lt; b.&amp;nbsp; Why?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data x;&lt;BR /&gt;a = 11*10;&lt;BR /&gt;b = (11/10)*100;&lt;BR /&gt;if a = b then put 'equal';&lt;BR /&gt;if a &amp;gt; b then put 'greater';&lt;BR /&gt;if a &amp;lt; b then put 'less';&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 15:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-SAS-calculation-error/m-p/720202#M223077</guid>
      <dc:creator>SAS1ns1ghts</dc:creator>
      <dc:date>2021-02-18T15:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent SAS calculation error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-SAS-calculation-error/m-p/720214#M223088</link>
      <description>&lt;P&gt;Do a google search for "sas numeric precision", and you will find the answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In short: decimal fractions cannot be exactly represented as binary data, so you introduce minimal aberrations during the calculation. When testing for equality, always use the ROUND() function before you compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW 11/10 can't even be represented exactly as a &lt;EM&gt;decimal&lt;/EM&gt; value, as it resolves to 1.1 periodic.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 15:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-SAS-calculation-error/m-p/720214#M223088</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-18T15:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent SAS calculation error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-SAS-calculation-error/m-p/720217#M223091</link>
      <description>Computers cannot store numbers exactly. &lt;BR /&gt;Almost all software applications can generate such an error.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lrcon&amp;amp;docsetTarget=p0ji1unv6thm0dn1gp4t01a1u0g6.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lrcon&amp;amp;docsetTarget=p0ji1unv6thm0dn1gp4t01a1u0g6.htm&amp;amp;locale=en&lt;/A&gt;</description>
      <pubDate>Thu, 18 Feb 2021 15:35:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-SAS-calculation-error/m-p/720217#M223091</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-18T15:35:51Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent SAS calculation error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-SAS-calculation-error/m-p/720230#M223099</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/181710"&gt;@SAS1ns1ghts&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See &lt;A href="https://communities.sas.com/t5/SAS-Programming/I-meet-with-a-problem-of-data-values-in-do-loops/m-p/691020/highlight/true#M210272" target="_blank" rel="noopener"&gt;this 2020 post&lt;/A&gt; for a detailed explanation why for SAS (under Windows)&amp;nbsp;&lt;FONT face="courier new,courier"&gt;0.07*100&amp;gt;7&lt;/FONT&gt; (!). Your example, &lt;FONT face="courier new,courier"&gt;1.1*100&amp;gt;110&lt;/FONT&gt;, is quite similar. The length of the period in the binary (periodic) fraction representing the decimal fraction 1.1 is 4, not 20 as in the case of 0.07, but the basic pattern is the same: a periodic fraction is rounded internally and the rounding error propagates in calculations.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Feb 2021 16:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-SAS-calculation-error/m-p/720230#M223099</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-02-18T16:00:14Z</dc:date>
    </item>
  </channel>
</rss>

