<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rounding/m-p/345899#M79653</link>
    <description>&lt;P&gt;Evidently,&amp;nbsp;"oldvar" is the incorrect spelling.&amp;nbsp; Run a PROC CONTENTS on&amp;nbsp; your incoming data set to find the correct spelling of the variable names.&lt;/P&gt;</description>
    <pubDate>Thu, 30 Mar 2017 18:53:25 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-03-30T18:53:25Z</dc:date>
    <item>
      <title>Rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding/m-p/345883#M79649</link>
      <description>&lt;PRE&gt;I wantto round 6274.5679 to the nearest integer to get 6275&lt;BR /&gt; &lt;BR /&gt;Here is what I wrote 

data want ; set have ;
format newvar 6. ;
newvar = Round(oldvar,1);
run;

the error i get is Variable  is oldvar uninitialized.&lt;BR /&gt;What mistake am I making.&lt;BR /&gt;&lt;BR /&gt;Randy&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Mar 2017 18:44:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding/m-p/345883#M79649</guid>
      <dc:creator>RandyStan</dc:creator>
      <dc:date>2017-03-30T18:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding/m-p/345899#M79653</link>
      <description>&lt;P&gt;Evidently,&amp;nbsp;"oldvar" is the incorrect spelling.&amp;nbsp; Run a PROC CONTENTS on&amp;nbsp; your incoming data set to find the correct spelling of the variable names.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 18:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding/m-p/345899#M79653</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-03-30T18:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding/m-p/345901#M79654</link>
      <description>&lt;P&gt;If you want the integer portion of a variable, the INT function is what you are looking for&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   value = 6274.5679;
   round_value = round(value);
   int_value = int(value);

   put round_value;
   put int_value;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Mar 2017 18:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding/m-p/345901#M79654</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-03-30T18:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding/m-p/345911#M79657</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data _null_;

  x=6274.4999;
  put x hex16.;

  /* here is the problem non-terminating mantissa
     cannot represent the number exactly - you have lost already.
     
  6274.4999
  40B8827FF9724745

  like 1/3 in decimal (never is exact)
   0.3333333333333
  */

  x=62744999;
  put x hex16.;

  /* got it exactly
  62744999
  418DEB4D38000000
  */

  x=6274.5;
  put x hex16.;

  /* got it exactly (when mantissa is a power of 2**(-n))
  6274.5
  40B8828000000000
  */

  /* possible solution;
   summing in the integer domain is exact (given no overflow);
   I don not think it has to be this complex;
  */

  input numchr $9.;
  put numchr;
  numchr=compress(numchr,'.');
  exact_integer=input(numchr,9.);
  put exact_integer hex16.;
  * in microcode this should be a bit shifting operation and should be exact?;
  res=round(exact_integer,10000);
  res=res/10000;
  put res 9.4;

cards4;
6274.4999
6274.5000
6274.5001
;;;;
run;quit;



&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Mar 2017 19:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding/m-p/345911#M79657</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-30T19:01:21Z</dc:date>
    </item>
  </channel>
</rss>

