<?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 Not getting expected results from FLOOR function on a whole number in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622801#M19849</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I have numeric values within my data where I simply would like to just drop the digits after the decimal point so I have a whole number.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Have 460.2866667&lt;/P&gt;&lt;P&gt;Want 460&lt;/P&gt;&lt;P&gt;Have 318.9816667&lt;/P&gt;&lt;P&gt;Want 318&lt;/P&gt;&lt;P&gt;So I am using the FLOOR function which is returning the correct results.&lt;/P&gt;&lt;P&gt;The problem i'm running into though is when I have a whole number....this is what is happening with the FLOOR function:&lt;/P&gt;&lt;P&gt;Have 824&lt;/P&gt;&lt;P&gt;Getting 823&lt;/P&gt;&lt;P&gt;Technically since the number is 824.00000000 and I want to just drop the numbers after the decimal point, I would hope to get a value of 824.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried FLOORZ and INT but it still gives me the 823 result.&lt;/P&gt;&lt;P&gt;Anyone have any ideas how to solve this?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2020 17:53:33 GMT</pubDate>
    <dc:creator>LRogers</dc:creator>
    <dc:date>2020-02-06T17:53:33Z</dc:date>
    <item>
      <title>Not getting expected results from FLOOR function on a whole number</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622801#M19849</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I have numeric values within my data where I simply would like to just drop the digits after the decimal point so I have a whole number.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Have 460.2866667&lt;/P&gt;&lt;P&gt;Want 460&lt;/P&gt;&lt;P&gt;Have 318.9816667&lt;/P&gt;&lt;P&gt;Want 318&lt;/P&gt;&lt;P&gt;So I am using the FLOOR function which is returning the correct results.&lt;/P&gt;&lt;P&gt;The problem i'm running into though is when I have a whole number....this is what is happening with the FLOOR function:&lt;/P&gt;&lt;P&gt;Have 824&lt;/P&gt;&lt;P&gt;Getting 823&lt;/P&gt;&lt;P&gt;Technically since the number is 824.00000000 and I want to just drop the numbers after the decimal point, I would hope to get a value of 824.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried FLOORZ and INT but it still gives me the 823 result.&lt;/P&gt;&lt;P&gt;Anyone have any ideas how to solve this?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 17:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622801#M19849</guid>
      <dc:creator>LRogers</dc:creator>
      <dc:date>2020-02-06T17:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting expected results from FLOOR function on a whole number</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622803#M19850</link>
      <description>&lt;P&gt;Almost definitely, your 824 is not an integer but actually 823.999999...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So floor is giving the correct answer. If you change the format of your variable to something like BEST32.16, do you see 824 or do you see 823.9999999...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 17:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622803#M19850</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-02-06T17:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting expected results from FLOOR function on a whole number</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622814#M19852</link>
      <description>&lt;P&gt;ROUND() the number first.&lt;/P&gt;
&lt;PRE&gt; 2  data x;
 3    a=824;
 4    b=824 - 1E-10 ;
 5    floora=floor(a);
 6    floorb=floor(b);
 7    floorb2=floor(round(b,1E-5));
 8    put (_all_) (=/) ;
 9  run;


a=824
b=824
floora=824
floorb=823
floorb2=824
&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Feb 2020 18:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622814#M19852</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-06T18:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting expected results from FLOOR function on a whole number</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622834#M19853</link>
      <description>&lt;P&gt;yes, when I do change to that format I see 823.99999999999&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 19:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622834#M19853</guid>
      <dc:creator>LRogers</dc:creator>
      <dc:date>2020-02-06T19:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting expected results from FLOOR function on a whole number</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622841#M19854</link>
      <description>&lt;P&gt;This is great!&amp;nbsp; The floor(round...)) worked perfectly!&amp;nbsp; Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 19:27:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622841#M19854</guid>
      <dc:creator>LRogers</dc:creator>
      <dc:date>2020-02-06T19:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Not getting expected results from FLOOR function on a whole number</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622871#M19857</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281120"&gt;@LRogers&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;yes, when I do change to that format I see 823.99999999999&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281120"&gt;@LRogers&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that you were just lucky that one of the common numeric formats (such as &lt;EM&gt;&lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n1n7bmvs1brl23n1dj9cbzau39df.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;w.d&lt;/A&gt;&lt;/EM&gt;, &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p1fum54c93f8r0n1wrs5mrb05nzi.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;BEST&lt;EM&gt;w&lt;/EM&gt;.&lt;/A&gt;&amp;nbsp;or&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p0ft9ab99s98msn1vblkk4c5bd3l.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;E&lt;EM&gt;w&lt;/EM&gt;.&lt;/A&gt;) revealed the small difference (most likely a rounding error) between the stored number and 824 directly. There are several &lt;EM&gt;different&lt;/EM&gt; numbers which these formats would display as if they were &lt;EM&gt;exactly&lt;/EM&gt; 824, because these formats do some rounding. (Needless to say, this is no special feature of the number 824.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are examples (assuming Windows or Unix operating systems):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input x hex16.;
cards;
4089BFFFFFFFFFFE
4089BFFFFFFFFFFF
4089C00000000000
4089C00000000001
4089C00000000002
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Among the above five numbers (entered as their internal hexadecimal representations) only the third is equal to 824, but you would need either&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;a special format, ideally one that shows the internal representation (such as &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=p1b6ugw71lmhnpn1wixijtysezzg.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;BINARY64.&lt;/A&gt; or &lt;A href="https://documentation.sas.com/?docsetId=leforinforref&amp;amp;docsetTarget=n0ueabv26pr2fwn19uxk2f4bf10y.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;HEX16.&lt;/A&gt;)&lt;/LI&gt;
&lt;LI&gt;or the (non-default) system option setting &lt;A href="https://documentation.sas.com/?docsetId=lesysoptsref&amp;amp;docsetTarget=n130tap9xs8q36n14gq23sci5y52.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;DECIMALCONV=&lt;/A&gt;STDIEEE (in conjunction with a sufficient &lt;EM&gt;w.d&lt;/EM&gt; format, e.g. 17.13)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;in order to distinguish it from the other four values by just looking at a formatted value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set test;
put x best32. +1 x 32.28 +1 x hex16.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result (under Windows SAS 9.4 using the default DECIMALCONV=COMPATIBLE):&lt;/P&gt;
&lt;PRE&gt;                             824 824.0000000000000000000000000000 4089BFFFFFFFFFFE
                             824 824.0000000000000000000000000000 4089BFFFFFFFFFFF
                             824 824.0000000000000000000000000000 4089C00000000000
                             824 824.0000000000000000000000000000 4089C00000000001
                             824 824.0000000000000000000000000000 4089C00000000002&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Numbers like the four "deviating" cases above can easily result from calculations (as a consequence of rounding errors in floating-point arithmetic and numeric representation error):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
x1=906.4/1.1;
x2=0.00824*100000;
run; /* Mathematically, both calculations result in 824, but ... */

proc print data=have noobs;
format x: hex16.;
run; /* ... not using the computer's floating-point arithmetic. */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result (Windows SAS 9.4):&lt;/P&gt;
&lt;PRE&gt;              x1                  x2

4089BFFFFFFFFFFF    4089C00000000001&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, it's always good to have the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0tj6cmga7p8qln1ejh6ebevm0c9.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;ROUND function&lt;/A&gt; at hand.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 21:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Not-getting-expected-results-from-FLOOR-function-on-a-whole/m-p/622871#M19857</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-02-06T21:08:14Z</dc:date>
    </item>
  </channel>
</rss>

