<?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: format w.d and rounding? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171678#M44274</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I looked at the distinct values.&amp;nbsp; They are dollar values.. nothing has more than 2 decimal places&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;interestingly enough when I then run this:&lt;/P&gt;&lt;P&gt;Proc print data=x;&lt;/P&gt;&lt;P&gt;Format &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;totallow&lt;/SPAN&gt; 14.2;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what prints out is &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;totallow=1077566016.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-decoration: underline; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;59&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-decoration: underline; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;so SAS is keeping it correctly but displaying it wrong.&amp;nbsp; ???&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 Oct 2014 19:00:37 GMT</pubDate>
    <dc:creator>Drez</dc:creator>
    <dc:date>2014-10-03T19:00:37Z</dc:date>
    <item>
      <title>format w.d and rounding?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171675#M44271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure why I get a different answer for these two statements.&amp;nbsp; Nothing is greater than 14 characters wide.&amp;nbsp; Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--------------------------------------------&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table x as&lt;/P&gt;&lt;P&gt;select sum(allow) as totallow, count(*) as rec_cnt&lt;/P&gt;&lt;P&gt;from MyData;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;totallow=1077566016.&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;60&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;rec_cnt=14403667&lt;/P&gt;&lt;P&gt;--------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table x2 as&lt;/P&gt;&lt;P&gt;select sum(allow) as totallow FORMAT=14.2, count(*) as rec_cnt&lt;/P&gt;&lt;P&gt;from MyData;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;totallow=1077566016.&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;59&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;rec_cnt=14403667&lt;/P&gt;&lt;P&gt;--------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MyData has 14403667 Rows and 36 Columns&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 14:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171675#M44271</guid>
      <dc:creator>Drez</dc:creator>
      <dc:date>2014-10-03T14:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: format w.d and rounding?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171676#M44272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;difference between BEST32.&amp;nbsp; and&amp;nbsp; &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;14.2&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 14:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171676#M44272</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-10-03T14:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: format w.d and rounding?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171677#M44273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The format difference is one explanation, easy to check with your resulting datasets.&lt;BR /&gt;Another possible rootcause could be the order at which the additions are made As you have a lot of observations this could be a summing of the precision error of each addition. Summing amounts that are almost equal will cause less loss of precision as summing ammounts that have a lot of difference. &lt;/P&gt;&lt;P&gt;eg adding 0.123456789012&amp;nbsp; to 12345678901,12&amp;nbsp; will lose a lot of the precision of you first amount. (remember 15 digits is the absolute maximum)&amp;nbsp; &lt;/P&gt;&lt;P&gt;As the order of summing with SQL (multi-threaded) is undetermined you can get small differences on each run. This effect requires knowing your data.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 15:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171677#M44273</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-10-03T15:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: format w.d and rounding?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171678#M44274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I looked at the distinct values.&amp;nbsp; They are dollar values.. nothing has more than 2 decimal places&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;interestingly enough when I then run this:&lt;/P&gt;&lt;P&gt;Proc print data=x;&lt;/P&gt;&lt;P&gt;Format &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;totallow&lt;/SPAN&gt; 14.2;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what prints out is &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;totallow=1077566016.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-decoration: underline; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;59&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; text-decoration: underline; background-color: #ffffff;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;so SAS is keeping it correctly but displaying it wrong.&amp;nbsp; ???&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 19:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171678#M44274</guid>
      <dc:creator>Drez</dc:creator>
      <dc:date>2014-10-03T19:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: format w.d and rounding?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171679#M44275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The w.d formats do not always round as we might expect as shown in the example below.&amp;nbsp; It is usually best to round to the desired precision and not leave it to w.d;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;46&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; data _null_;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;47&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do x = &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1e-16&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, round(x,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;.01&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;48&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; put;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;49&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; put x=;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;50&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; put x=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;6.2&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;51&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; put x=&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;bestx6.2&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;52&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; end;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;53&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&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;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;x&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1E-16&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;x=-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0.00&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;x=-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0.00&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;BR /&gt;x=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;x=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0.00&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;x=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;0.00&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Oct 2014 19:41:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171679#M44275</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-10-03T19:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: format w.d and rounding?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171680#M44276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Having changed the format has proved the difference in rounding is in the formats.&lt;/P&gt;&lt;P&gt;&amp;nbsp; As a pitty it is not well documented how rounding is done behind scenes.&lt;/P&gt;&lt;P&gt;data_null_ has given another example&amp;nbsp; how rounding effects can give odd results. The - sign is a nice example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be added:&lt;/P&gt;&lt;P&gt;We are into the digital ages no not digital numbers but binary numbers.&amp;nbsp; &lt;A href="https://support.sas.com/techsup/technote/ts654.pdf" title="https://support.sas.com/techsup/technote/ts654.pdf"&gt;https://support.sas.com/techsup/technote/ts654.pdf&lt;/A&gt; &lt;/P&gt;&lt;P&gt;Your decimal fractions are not possible to be represented exactly in their binary counterparts.&amp;nbsp; That will introduce some of precision differences as data_null_ coded manual.&amp;nbsp; Having the summing done as integers on dollarcents would have avoided fractions.&lt;/P&gt;&lt;P&gt;The format Best. (that default) is said to adjust to most applicable resolution. That is all what is said about that.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#p1fum54c93f8r0n1wrs5mrb05nzi.htm" title="http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#p1fum54c93f8r0n1wrs5mrb05nzi.htm"&gt;SAS(R) 9.4 Formats and Informats: Reference&lt;/A&gt; More interesting is the &lt;A href="http://support.sas.com/documentation/cdl/en/lesysoptsref/67465/HTML/default/viewer.htm#n130tap9xs8q36n14gq23sci5y52.htm" title="http://support.sas.com/documentation/cdl/en/lesysoptsref/67465/HTML/default/viewer.htm#n130tap9xs8q36n14gq23sci5y52.htm"&gt;SAS(R) 9.4 System Options: Reference, Third Edition&lt;/A&gt; decimalconv= system option. It refers to: IEEE Standard for Floating-Point Arithmetic 754-2008. SAS did not conform to that but can now.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Oct 2014 06:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/format-w-d-and-rounding/m-p/171680#M44276</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2014-10-04T06:46:52Z</dc:date>
    </item>
  </channel>
</rss>

