<?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 up or down based on conditions &amp;gt;X.5 or &amp;lt;=X.5 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rounding-up-or-down-based-on-conditions-gt-X-5-or-lt-X-5/m-p/562702#M157648</link>
    <description>&lt;P&gt;This is exactly what the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0tj6cmga7p8qln1ejh6ebevm0c9.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;Round Function&lt;/A&gt; does?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   do x=1 to 10;
      y=x*rand('uniform');
      output;
   end;
run;

data want;
   set have;
   z=round(y);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 30 May 2019 20:10:48 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-05-30T20:10:48Z</dc:date>
    <item>
      <title>Rounding up or down based on conditions &gt;X.5 or &lt;=X.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-up-or-down-based-on-conditions-gt-X-5-or-lt-X-5/m-p/562700#M157647</link>
      <description>&lt;P&gt;Hi, If I would like to round up or down for a specific variable in a dataset under these two conditions, what would be the best/easiest way to do this in SAS?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For decimal value outcomes &amp;lt; X.5, round down to the nearest integer&lt;/P&gt;&lt;P&gt;For decimal value outcomes ≥ X.5, round up to the nearest integer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've seen it done as a do loop, but that seems overly complicated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is much appreciated, thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 20:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-up-or-down-based-on-conditions-gt-X-5-or-lt-X-5/m-p/562700#M157647</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2019-05-30T20:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up or down based on conditions &gt;X.5 or &lt;=X.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-up-or-down-based-on-conditions-gt-X-5-or-lt-X-5/m-p/562702#M157648</link>
      <description>&lt;P&gt;This is exactly what the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=p0tj6cmga7p8qln1ejh6ebevm0c9.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;Round Function&lt;/A&gt; does?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
   do x=1 to 10;
      y=x*rand('uniform');
      output;
   end;
run;

data want;
   set have;
   z=round(y);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 May 2019 20:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-up-or-down-based-on-conditions-gt-X-5-or-lt-X-5/m-p/562702#M157648</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-05-30T20:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up or down based on conditions &gt;X.5 or &lt;=X.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-up-or-down-based-on-conditions-gt-X-5-or-lt-X-5/m-p/562726#M157666</link>
      <description>&lt;P&gt;And for extra added fun you can actually round to the nearest multiple of a given number. The default is 1 if not supplied.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
   do x=1 to 10;
      z= rand('uniform');
      y1= round(x*z,1);
      y2= round(x*z,2);
      y3= round(x*z,.7);
      y4= round(x*z,2.5);
      output;
   end;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 May 2019 22:08:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-up-or-down-based-on-conditions-gt-X-5-or-lt-X-5/m-p/562726#M157666</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-30T22:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding up or down based on conditions &gt;X.5 or &lt;=X.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rounding-up-or-down-based-on-conditions-gt-X-5-or-lt-X-5/m-p/562727#M157667</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/139341"&gt;@kmardinian&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;For decimal value outcomes &amp;lt; X.5, round down to the nearest integer&lt;/P&gt;
&lt;P&gt;For decimal value outcomes ≥ X.5, round up to the nearest integer&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is different than the title of this thread, and if you really mean the title of this thread, then the answer given is not correct. Just saying...&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2019 22:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rounding-up-or-down-based-on-conditions-gt-X-5-or-lt-X-5/m-p/562727#M157667</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-30T22:18:50Z</dc:date>
    </item>
  </channel>
</rss>

