<?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: Division Function Not returning exact decimal place. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778625#M247870</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279633"&gt;@whs278&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279633"&gt;@whs278&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here is the output of PROC CONTENTS.&amp;nbsp;&lt;FONT color="#FF0000"&gt; I didn't add any formats.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;41 FAVINC1A Num 8 BEST32. &lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;(So, BEST32. in your partial PROC CONTENTS output is the &lt;U&gt;in&lt;/U&gt;format.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess you can mark&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;'s reply as the solution because not using any formats, e.g., in PROC PRINT output produces exactly what you've described:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input b c;
a = round(b/c, .001);
x = b/c;
cards;
72538200 896
;

proc print data=have;
*format a x best12.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs        b        c         a           x

 1     72538200    896    80957.81    80957.81&lt;/PRE&gt;
&lt;P&gt;Of course the missing digits will appear as soon as you run the code including the FORMAT statement that I've commented out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 22:43:56 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-11-04T22:43:56Z</dc:date>
    <item>
      <title>Division Function Not returning exact decimal place.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778611#M247863</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following code in my program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;a = round(b/c, .001);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, all the numbers get rounded to the hundredths place instead of the thousandths place.&amp;nbsp; In fact, when I remove the round function, I still only get two decimal places.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure what is going on.&amp;nbsp; Tried using and not using BEST32. informat, but still got the same answer.&amp;nbsp; I got the same result with the DIVISION function as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are the actual numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2538200 / 896 = 80957.81&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 21:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778611#M247863</guid>
      <dc:creator>whs278</dc:creator>
      <dc:date>2021-11-04T21:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Division Function Not returning exact decimal place.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778612#M247864</link>
      <description>&lt;P&gt;INFORMAT would have no bearing on display appearance. The Format would.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;40   data example;
41      x=2538200 / 896 ;
42      put x= best16.;
43      x = round(x,0.001);
44      put "second " x=;
45   run;

x=2832.8125
second x=2832.813
&lt;/PRE&gt;
&lt;P&gt;So if you get 80957.81 as a result there is something much more interesting going on then just the display format. Perhaps you should show the &lt;STRONG&gt;entire data step&lt;/STRONG&gt; code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 22:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778612#M247864</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-04T22:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Division Function Not returning exact decimal place.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778613#M247865</link>
      <description>&lt;P&gt;It works for me. Show us more of what you are doing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data T; 
x= round(2538200 / 896 ,0.001);
put x= ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;x=2832.813&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 22:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778613#M247865</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-04T22:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Division Function Not returning exact decimal place.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778615#M247866</link>
      <description>&lt;P&gt;You have presented a single statement without any context.&lt;/P&gt;
&lt;P&gt;Since it looks like an assignment statement let's assume you have run it in a data step.&lt;/P&gt;
&lt;P&gt;How did you look at the result?&amp;nbsp; Did you print it? Do something else?&lt;/P&gt;
&lt;P&gt;Have you attached a display format to the variable A?&amp;nbsp; How many decimal places did you choose to display in the format you attached to the variable?&lt;/P&gt;
&lt;PRE&gt;871   data _null_;
872     a = 2538200 / 896 ;
873     b = round(a,0.001);
874     put 'BEST32.' / (a b) (=best32.);
875     put '32.2' / (a b) (=32.2);
876     put ' ' / (a b) (= );
877
878   run;

BEST32.
a=2832.8125 b=2832.813
32.2
a=2832.81 b=2832.81

a=2832.8125 b=2832.813
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 22:10:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778615#M247866</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-04T22:10:17Z</dc:date>
    </item>
    <item>
      <title>Re: Division Function Not returning exact decimal place.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778621#M247868</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's pretty much the same code I posted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA CENSACS;
	SET CENSACS2;

	/*AVERAGE FAMILY INCOME*/
	INFORMAT B19127_001 B19101_001 FAVINC1A BEST32.; 
	FAVINC1A  = DIVIDE( B19127_001,  B19101_001);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;    RENAME  B19127_001 = FAVINC1AN &lt;BR /&gt;            B19101_001 = FAVINC1AD;&lt;BR /&gt;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the output of PROC CONTENTS.&amp;nbsp; I didn't add any formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;41 FAVINC1A Num 8 BEST32. &lt;BR /&gt;32 FAVINC1AD Num 8 BEST32. &lt;BR /&gt;34 FAVINC1AN Num 8 BEST32.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 22:25:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778621#M247868</guid>
      <dc:creator>whs278</dc:creator>
      <dc:date>2021-11-04T22:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: Division Function Not returning exact decimal place.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778625#M247870</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279633"&gt;@whs278&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279633"&gt;@whs278&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Here is the output of PROC CONTENTS.&amp;nbsp;&lt;FONT color="#FF0000"&gt; I didn't add any formats.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;41 FAVINC1A Num 8 BEST32. &lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;(So, BEST32. in your partial PROC CONTENTS output is the &lt;U&gt;in&lt;/U&gt;format.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess you can mark&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;'s reply as the solution because not using any formats, e.g., in PROC PRINT output produces exactly what you've described:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input b c;
a = round(b/c, .001);
x = b/c;
cards;
72538200 896
;

proc print data=have;
*format a x best12.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs        b        c         a           x

 1     72538200    896    80957.81    80957.81&lt;/PRE&gt;
&lt;P&gt;Of course the missing digits will appear as soon as you run the code including the FORMAT statement that I've commented out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 22:43:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Division-Function-Not-returning-exact-decimal-place/m-p/778625#M247870</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-11-04T22:43:56Z</dc:date>
    </item>
  </channel>
</rss>

