<?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 issue in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549380#M33397</link>
    <description>&lt;P&gt;what about or a like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if int(var+0.9) = int(var) then result=var;
else result=int(var+0.9);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Apr 2019 18:38:59 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2019-04-08T18:38:59Z</dc:date>
    <item>
      <title>rounding issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549370#M33394</link>
      <description>&lt;P&gt;Hello SAS world.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Today I'm trying to find an easy way (hopefully) to do some column rounding based on a value in the &lt;U&gt;first digit to the RIGHT of a decimal point&lt;/U&gt;, with a computed column in EG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially If the first digit is a '1' or greater,&amp;nbsp; I want to round UP to the next whole number, otherwise.. it remains the same whole number. At the end.. the result data column will be formatted to be only a whole number, no decimal positions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;So: &lt;/U&gt;&lt;/P&gt;&lt;P&gt;'2.0122' would be returned as '2.00' or '2.0122'&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;'2.1203'&amp;nbsp; would be '3.00' or '3.1203'&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;'4.6129' would be '5.00' or '5.6129'&lt;/P&gt;&lt;P&gt;'0.099' would be '0'&lt;/P&gt;&lt;P&gt;'0.111' would be '1' or '1.111'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My first thought was to convert the value to a character value, then use a sub-string to get the first 'digit', then to use a case statement to determine what to do..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sure there is something easier, more efficient to do this with. I just haven't learned it yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked into FLOOR, CEIL, ROUND functions.. but I don't see anything that suggests I can control what position is judged, and how the controlling argument (.1) is assigned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Ideas would be very appreciated.&lt;/P&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 18:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549370#M33394</guid>
      <dc:creator>cnilsen</dc:creator>
      <dc:date>2019-04-08T18:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: rounding issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549372#M33395</link>
      <description>&lt;P&gt;Extract the first digit to the right of the decimal from a numeric variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;decimal = x - floor(x);
first_digit = floor(10*decimal);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Round according to your rules&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first_digit &amp;gt;= 1 then x = ceil(x);
else x = floor(x);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 18:22:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549372#M33395</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-08T18:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: rounding issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549373#M33396</link>
      <description>&lt;P&gt;You're hunting in the right ballpark.&amp;nbsp; Try it this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if var &amp;gt;= int(var) + 0.1 then var = ceil(var);
else var = int(var);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The logic is designed for positive numbers.&amp;nbsp; If you can have negative numbers, you might have to specify a different formula, based on a different set of rules.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2019 18:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549373#M33396</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-08T18:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: rounding issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549380#M33397</link>
      <description>&lt;P&gt;what about or a like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if int(var+0.9) = int(var) then result=var;
else result=int(var+0.9);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Apr 2019 18:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549380#M33397</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-04-08T18:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: rounding issue</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549391#M33398</link>
      <description>This worked awsome. I made a small change to use FLOOR in the else result so I ending up with whole numbers no matter what.. Thanks to all who posted with solutions!</description>
      <pubDate>Mon, 08 Apr 2019 19:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/rounding-issue/m-p/549391#M33398</guid>
      <dc:creator>cnilsen</dc:creator>
      <dc:date>2019-04-08T19:14:05Z</dc:date>
    </item>
  </channel>
</rss>

