<?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 to nearest decimal without changing integer value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685074#M207720</link>
    <description>&lt;P&gt;This is most unusual. But can be done:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do x = 2.9546732, 4.5423, 4.5734, 0.983764, 9.89473, 9.99999964;
    y = int(x) + ifn(x-int(x) &amp;gt;= 0.9, 0.9, round(x-int(x),0.1));
    put x= y=;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; x=2.9546732 y=2.9
 x=4.5423 y=4.5
 x=4.5734 y=4.6
 x=0.983764 y=0.9
 x=9.89473 y=9.9
 x=9.99999964 y=9.9&lt;/PRE&gt;</description>
    <pubDate>Fri, 18 Sep 2020 19:38:06 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-09-18T19:38:06Z</dc:date>
    <item>
      <title>Rounding to nearest decimal without changing integer value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685066#M207717</link>
      <description>&lt;P&gt;I have a set of values which have a large number of digits to the right of the decimal.&amp;nbsp; I need a way to round to the nearest&amp;nbsp;&lt;EM&gt;tenth&amp;nbsp;&lt;/EM&gt;while NOT rounding up to the next integer if the decimal value is &amp;gt;= .95 .&amp;nbsp; For instance:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Raw Value&amp;nbsp; --&amp;nbsp; Preferred Rounded Value&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;2.9546732 -- 2.9&lt;/P&gt;
&lt;P&gt;4.5423 -- 4.5&lt;/P&gt;
&lt;P&gt;4.5734 -- 4.6&lt;/P&gt;
&lt;P&gt;0.983764 -- 0.9&lt;/P&gt;
&lt;P&gt;9.89473 -- 9.9&lt;/P&gt;
&lt;P&gt;9.99999964 -- 9.9&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea on how to perform this?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 18:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685066#M207717</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2020-09-18T18:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding to nearest decimal without changing integer value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685073#M207719</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/264750"&gt;@RandoDando&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a set of values which have a large number of digits to the right of the decimal.&amp;nbsp; I need a way to round to the nearest&amp;nbsp;&lt;EM&gt;tenth&amp;nbsp;&lt;/EM&gt;while NOT rounding up to the next integer if the decimal value is &amp;gt;= .95 .&amp;nbsp; For instance:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Raw Value&amp;nbsp; --&amp;nbsp; Preferred Rounded Value&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;2.9546732 -- 2.9&lt;/P&gt;
&lt;P&gt;4.5423 -- 4.5&lt;/P&gt;
&lt;P&gt;4.5734 -- 4.6&lt;/P&gt;
&lt;P&gt;0.983764 -- 0.9&lt;/P&gt;
&lt;P&gt;9.89473 -- 9.9&lt;/P&gt;
&lt;P&gt;9.99999964 -- 9.9&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any idea on how to perform this?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you have a similar aversion to rounding down to an integer such as when the value is 10.04 where the nearest tenth would be 10.0?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 19:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685073#M207719</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-18T19:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding to nearest decimal without changing integer value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685074#M207720</link>
      <description>&lt;P&gt;This is most unusual. But can be done:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
do x = 2.9546732, 4.5423, 4.5734, 0.983764, 9.89473, 9.99999964;
    y = int(x) + ifn(x-int(x) &amp;gt;= 0.9, 0.9, round(x-int(x),0.1));
    put x= y=;
    end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt; x=2.9546732 y=2.9
 x=4.5423 y=4.5
 x=4.5734 y=4.6
 x=0.983764 y=0.9
 x=9.89473 y=9.9
 x=9.99999964 y=9.9&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Sep 2020 19:38:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685074#M207720</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-09-18T19:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding to nearest decimal without changing integer value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685075#M207721</link>
      <description>&lt;P&gt;num = int(num*10) / 10;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 19:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685075#M207721</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-09-18T19:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding to nearest decimal without changing integer value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685098#M207729</link>
      <description>No, I do not.  If it is 10.04, I would want just 10.&lt;BR /&gt;</description>
      <pubDate>Fri, 18 Sep 2020 20:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685098#M207729</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2020-09-18T20:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding to nearest decimal without changing integer value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685448#M207881</link>
      <description>I know it is out of the ordinary, but this is only for a displayed value and not being used in any other analyses.</description>
      <pubDate>Mon, 21 Sep 2020 14:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-to-nearest-decimal-without-changing-integer-value/m-p/685448#M207881</guid>
      <dc:creator>RandoDando</dc:creator>
      <dc:date>2020-09-21T14:37:25Z</dc:date>
    </item>
  </channel>
</rss>

