<?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: Rounding a Number in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631499#M187111</link>
    <description>&lt;P&gt;As others have already remarked, SAS should give the same result as your calculator. There are a couple of exceptions: If your numeric variables have a length shorter than 8, which will reduce precision of the numeric variables, or if your numeric variables are not really the values displayed, but shown rounded as you see them, because a format applied to them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So take a look at the variables in your input data: what lengths do the variables have, and what formats?&lt;/P&gt;</description>
    <pubDate>Thu, 12 Mar 2020 09:50:19 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2020-03-12T09:50:19Z</dc:date>
    <item>
      <title>Rounding a Number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631492#M187104</link>
      <description>&lt;P&gt;I have three &lt;STRONG&gt;numeric&lt;/STRONG&gt; variables that I am multiplying. I get different results when I multiply them by a calculator and by SAS. Below are three variables and an example of values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A = 4345&lt;/P&gt;&lt;P&gt;B = .0057&lt;/P&gt;&lt;P&gt;C = .40&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a * b * c = x&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;by calculator&lt;/STRONG&gt;: 4345 * 0057 *.40 = &lt;STRONG&gt;9.9066&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;by SAS&lt;/STRONG&gt;: 4345 * 0057 * .40 = &lt;STRONG&gt;9.831&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe the culprit it '0057' number. I am thinking that may be it has to with rounding so I tried but did not work. May be I am not rounding it correctly?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I get 9.9066 from SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 09:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631492#M187104</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2020-03-12T09:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a Number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631494#M187106</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/283628"&gt;@SASMom2&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run the following code,&amp;nbsp;I get the result&amp;nbsp;&lt;SPAN&gt;9.9066&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input A B C;
	x = A*B*C;
	datalines;
4345 .0057 .40
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Could you please run a proc contents on your table to visualize the type of B and also its format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=have;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 09:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631494#M187106</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-03-12T09:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a Number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631495#M187107</link>
      <description>Can you post your code please, I am getting the same output as the calculator.</description>
      <pubDate>Thu, 12 Mar 2020 09:34:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631495#M187107</guid>
      <dc:creator>sustagens</dc:creator>
      <dc:date>2020-03-12T09:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a Number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631498#M187110</link>
      <description>&lt;P&gt;Below is the result from the Proc Content.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;TABLE cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;F12.4&lt;/TD&gt;&lt;TD&gt;BEST12.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;Num&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;F12.2&lt;/TD&gt;&lt;TD&gt;BEST12.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 09:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631498#M187110</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2020-03-12T09:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a Number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631499#M187111</link>
      <description>&lt;P&gt;As others have already remarked, SAS should give the same result as your calculator. There are a couple of exceptions: If your numeric variables have a length shorter than 8, which will reduce precision of the numeric variables, or if your numeric variables are not really the values displayed, but shown rounded as you see them, because a format applied to them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So take a look at the variables in your input data: what lengths do the variables have, and what formats?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 09:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631499#M187111</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-03-12T09:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a Number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631500#M187112</link>
      <description>&lt;P&gt;The code is long but basically, below is calculation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="3"&gt;&lt;STRONG&gt;&lt;FONT face="Courier New"&gt;(c.avg_mship*a.acp*a.capture_rate) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New"&gt; Annual_Target&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 09:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631500#M187112</guid>
      <dc:creator>SASMom2</dc:creator>
      <dc:date>2020-03-12T09:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a Number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631506#M187117</link>
      <description>&lt;P&gt;Your code does not do what you say.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  input A B C;
  X = A*B*C;
  putlog X=;
datalines;
4345 .0057 .40
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, Courier, 'Courier New'; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"&gt;X=9.9066&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 10:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631506#M187117</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-03-12T10:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a Number</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631508#M187118</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select A*B*C 'P' from  HAVE;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE&gt;
&lt;THEAD&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TH class="r b header" style="text-align: right; padding: 3px 6px; vertical-align: bottom; background-color: #edf2f9; border-color: #b0b7bb; border-style: solid; border-width: 0px 1px 1px 0px; color: #112277; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: bold;" scope="col"&gt;P&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR style="border-top: 1px solid #c1c1c1; border-bottom: 0px solid #c1c1c1;"&gt;
&lt;TD class="r data" style="text-align: right; padding: 3px 6px; vertical-align: top; background-color: #ffffff; border-color: #c1c1c1; border-style: solid; border-width: 0px 1px 1px 0px; font-family: Arial, 'Albany AMT', Helvetica, Helv; font-size: x-small; font-style: normal; font-weight: normal;"&gt;9.9066&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 12 Mar 2020 10:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-a-Number/m-p/631508#M187118</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-03-12T10:23:32Z</dc:date>
    </item>
  </channel>
</rss>

