<?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: When using Sum function on dollar amounts additional decimal places are introduced in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105230#M258454</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A __default_attr="5253" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt; ! Something like this is where we will end up Im sure. We are actually trying to validate a stored procedure in SQL using SAS so we were trying to reduce the rounding as much as possible to eliminate steps were mismatching can occur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Oct 2013 13:07:44 GMT</pubDate>
    <dc:creator>esjackso</dc:creator>
    <dc:date>2013-10-07T13:07:44Z</dc:date>
    <item>
      <title>When using Sum function on dollar amounts additional decimal places are introduced</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105225#M258449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Im sure this might be an easy question that we cant see right now being in the midst of problem, but we are summing a numeric variable using a number of methods (sum function sql, proc means, data step with retain) by an id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looking at the raw data there appears to be nothing beyond two decimal places in the data. We confirm this after getting it in sas by taking the difference of the variable round to 2 places and the variable without rounding and get no differences between the two.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However after we sum by any of the methods and we take the difference between the rounded sum and the actual sum we are getting differences.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;We cant figure out why this is happening or if we are causing it somehow.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt; &lt;/SPAN&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 12:27:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105225#M258449</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-10-07T12:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: When using Sum function on dollar amounts additional decimal places are introduced</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105226#M258450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eric, not sure if this is your case, but it has been long known that there could be some precision issue if 'minus' operation or summary with negative numbers involves.&amp;nbsp; Please see the following example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt; a=2.16;b=-1.17;&lt;/P&gt;&lt;P&gt; raw_c=sum(a,b);&lt;/P&gt;&lt;P&gt; round_c=round(raw_c,0.01);&lt;/P&gt;&lt;P&gt; put raw_c= round_c=;&lt;/P&gt;&lt;P&gt; if raw_c=round_c then put "equal" ; else put "not equal";&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;They are indeed not equal to SAS if you put hex20. to check it out. The safe way to deal with it is to use round() to maintain the precision level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 12:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105226#M258450</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-10-07T12:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: When using Sum function on dollar amounts additional decimal places are introduced</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105227#M258451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another approach to dealing with the problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Multiply all values by 100.&amp;nbsp; Round to the nearest integer.&amp;nbsp; Sum.&amp;nbsp; Divide the sum by 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Precision issues are nearly nonexistent when dealing with integers.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 13:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105227#M258451</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2013-10-07T13:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: When using Sum function on dollar amounts additional decimal places are introduced</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105228#M258452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A __default_attr="5068" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/" modifiedtitle="true" title="Hai.kuo"&gt;&lt;/A&gt; for the response but our values are all positive or zero.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 13:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105228#M258452</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-10-07T13:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: When using Sum function on dollar amounts additional decimal places are introduced</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105229#M258453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://support.sas.com/techsup/technote/ts654.pdf" title="http://support.sas.com/techsup/technote/ts654.pdf"&gt;http://support.sas.com/techsup/technote/ts654.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;17&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;18&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array a[&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;10&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;] (&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;10&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;*&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;.1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;19&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain b &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;20&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = sum(of a&lt;LI&gt;);&lt;BR /&gt;&lt;/LI&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;21&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put (b c)(=&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;hex16.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;22&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put (b c)(=&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;best32.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;23&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;b=3FF0000000000000 c=3FEFFFFFFFFFFFFF&lt;BR /&gt;b=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; c=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 13:05:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105229#M258453</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-10-07T13:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: When using Sum function on dollar amounts additional decimal places are introduced</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105230#M258454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A __default_attr="5253" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt; ! Something like this is where we will end up Im sure. We are actually trying to validate a stored procedure in SQL using SAS so we were trying to reduce the rounding as much as possible to eliminate steps were mismatching can occur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 13:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105230#M258454</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-10-07T13:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: When using Sum function on dollar amounts additional decimal places are introduced</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105231#M258455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Bingo!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 13:11:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105231#M258455</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2013-10-07T13:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: When using Sum function on dollar amounts additional decimal places are introduced</title>
      <link>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105232#M258456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks everyone ... I thought it was something like that but I couldnt explain it very well but the technote was perfect&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EJ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Oct 2013 13:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/When-using-Sum-function-on-dollar-amounts-additional-decimal/m-p/105232#M258456</guid>
      <dc:creator>esjackso</dc:creator>
      <dc:date>2013-10-07T13:17:08Z</dc:date>
    </item>
  </channel>
</rss>

