<?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 value up to nearest value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rounding-value-up-to-nearest-value/m-p/497751#M132045</link>
    <description>&lt;P&gt;You would use the round function.&amp;nbsp; However you would first take the lengthn(put(number,best.)), then remove 2 from that and then use that to create your rounding amount.&amp;nbsp; Something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  orig=6458903;
  num=lengthn(strip(put(orig,best.)))-2;
  roundto=cats("1",repeat("0",num-1));
  new=round(orig,roundto);
run;&lt;/PRE&gt;
&lt;P&gt;Note I have specifically left all the working out and made it verbose to show the process, you can shrink it down.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Sep 2018 10:23:23 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-09-21T10:23:23Z</dc:date>
    <item>
      <title>Rounding value up to nearest value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-value-up-to-nearest-value/m-p/497750#M132044</link>
      <description>&lt;P&gt;suppose i have a column named number and it has a value like 6458903 and i want this value in target table as 6500000&lt;/P&gt;
&lt;P&gt;and its length is not fixed how we can do this.??&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 10:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-value-up-to-nearest-value/m-p/497750#M132044</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2018-09-21T10:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding value up to nearest value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-value-up-to-nearest-value/m-p/497751#M132045</link>
      <description>&lt;P&gt;You would use the round function.&amp;nbsp; However you would first take the lengthn(put(number,best.)), then remove 2 from that and then use that to create your rounding amount.&amp;nbsp; Something like:&lt;/P&gt;
&lt;PRE&gt;data want;
  orig=6458903;
  num=lengthn(strip(put(orig,best.)))-2;
  roundto=cats("1",repeat("0",num-1));
  new=round(orig,roundto);
run;&lt;/PRE&gt;
&lt;P&gt;Note I have specifically left all the working out and made it verbose to show the process, you can shrink it down.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Sep 2018 10:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-value-up-to-nearest-value/m-p/497751#M132045</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-21T10:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding value up to nearest value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-value-up-to-nearest-value/m-p/497753#M132047</link>
      <description>Thanks for the solution '_'</description>
      <pubDate>Fri, 21 Sep 2018 10:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-value-up-to-nearest-value/m-p/497753#M132047</guid>
      <dc:creator>Son_Of_Krypton</dc:creator>
      <dc:date>2018-09-21T10:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding value up to nearest value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-value-up-to-nearest-value/m-p/497763#M132055</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;146  data _null_;
147     do orig=6458903,670,456123,32,645890,64589,6458,645,64,6;
148        l = ceil(log10(orig));
149        u = 10**(l-2);
150        round = round(orig,U);
151        put (_all_)(=);
152        end;
153     run;

orig=6458903 l=7 u=100000 round=6500000
orig=670 l=3 u=10 round=670
orig=456123 l=6 u=10000 round=460000
orig=32 l=2 u=1 round=32
orig=645890 l=6 u=10000 round=650000
orig=64589 l=5 u=1000 round=65000
orig=6458 l=4 u=100 round=6500
orig=645 l=3 u=10 round=650
orig=64 l=2 u=1 round=64
orig=6 l=1 u=0.1 round=6
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Sep 2018 12:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-value-up-to-nearest-value/m-p/497763#M132055</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-09-21T12:04:54Z</dc:date>
    </item>
  </channel>
</rss>

