<?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 integers (whole number) or 0.5 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606175#M175995</link>
    <description>&lt;P&gt;Your posted results don't follow your rules. 8.67 should go to 8.5 not 9.0. 8.76 would round up to 9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use ROUND() function to round to the nearest 0.5.&amp;nbsp; To force the .25 and .75 to round down instead of up subtract a small delta.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=round(depth-0.001,0.5);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 21 Nov 2019 15:44:33 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-11-21T15:44:33Z</dc:date>
    <item>
      <title>rounding to integers (whole number) or 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606170#M175991</link>
      <description>&lt;P&gt;Dear friends,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have depth which increases by 0.5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like to join it to other numbers which are real numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like to round my real numbers to closest integer or 0.5 which can be joined to my integer numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The rules are:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Decimals between 0 and 25 will be round down to 0 (22.25 will be 22.0)&lt;/P&gt;
&lt;P&gt;Decimals between 26 and 49 will be round up to 50 (22. 27 will be 22.50)&lt;/P&gt;
&lt;P&gt;Decimals between 51 and 75 will be round down to 50 (22. 57 will be 22.50)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Decimals between 76 and 99 will be round up to whole number (22. 77 will be 23.0)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's look at my numbers. I have the following table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Table1&lt;/P&gt;
&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;depth&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;0,18&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;0,56&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1,12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1,45&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5,25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5,26&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;6,66&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7,11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8,67&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;9,11&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10,67&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I like the above table be like this:&lt;/P&gt;
&lt;P&gt;Table2&lt;/P&gt;
&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;&lt;STRONG&gt;depth&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;0,0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;0,5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1,0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1,5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5,0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;5,5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7,0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;7,0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;8,5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;9,0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;10,5&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you please help me with it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Farshid Owrang&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 15:46:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606170#M175991</guid>
      <dc:creator>farshidowrang</dc:creator>
      <dc:date>2019-11-21T15:46:06Z</dc:date>
    </item>
    <item>
      <title>Re: rounding to integers (whole number) or 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606174#M175994</link>
      <description>&lt;P&gt;The want-table is not conform to the description.In the last line you have 10.67, according to the description ("Decimals between 51 and 75 will be round down to 50 (22. 57 will be 22.50) ") the result should be 10.5, not 11.0. If 10.5 is the right result, then use the round function with 0.5 as second parameter.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 15:41:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606174#M175994</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-11-21T15:41:24Z</dc:date>
    </item>
    <item>
      <title>Re: rounding to integers (whole number) or 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606175#M175995</link>
      <description>&lt;P&gt;Your posted results don't follow your rules. 8.67 should go to 8.5 not 9.0. 8.76 would round up to 9.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use ROUND() function to round to the nearest 0.5.&amp;nbsp; To force the .25 and .75 to round down instead of up subtract a small delta.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=round(depth-0.001,0.5);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Nov 2019 15:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606175#M175995</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-21T15:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: rounding to integers (whole number) or 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606176#M175996</link>
      <description>&lt;P&gt;Sorry&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are completely right&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should be 10.5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will fix it in the table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 15:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606176#M175996</guid>
      <dc:creator>farshidowrang</dc:creator>
      <dc:date>2019-11-21T15:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: rounding to integers (whole number) or 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606179#M175997</link>
      <description>&lt;P&gt;Dear friend&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems it works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Farshid Owrang&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 16:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606179#M175997</guid>
      <dc:creator>farshidowrang</dc:creator>
      <dc:date>2019-11-21T16:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: rounding to integers (whole number) or 0.5</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606231#M176023</link>
      <description>Please select the correct answer, not this response, and mark it as the solution to let others know this is solved.</description>
      <pubDate>Thu, 21 Nov 2019 17:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rounding-to-integers-whole-number-or-0-5/m-p/606231#M176023</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-21T17:44:20Z</dc:date>
    </item>
  </channel>
</rss>

