<?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: Query on Rounding off in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243506#M55944</link>
    <description>&lt;P&gt;You seem to have already answered your own question there:&lt;/P&gt;
&lt;P&gt;data roundtest; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set &amp;lt;libref&amp;gt;.filename;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; y=round(y,0.1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; w=round(w,0.1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ...;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jan 2016 16:42:25 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-01-14T16:42:25Z</dc:date>
    <item>
      <title>Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243505#M55943</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I am Shriram from Bangalore, India. I am new to this community/forum. I have just about started learning SAS and have lots of doubts.&lt;/P&gt;&lt;P&gt;I would be glad and grateful if anyone can give me pointers on how to approach the subject, how to ask mny questions and any other suggestions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Heres is to a start of our association:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Scenario 1: No problems and it works fine&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;x=123.45567;&lt;/P&gt;&lt;P&gt;y=round(x,0.1); /* nth decimal place*/&lt;/P&gt;&lt;P&gt;z=round(x,100); /* nearest 100 place*/&lt;/P&gt;&lt;P&gt;m=round(x,10); &amp;nbsp;/*nearest 10 place*/&lt;/P&gt;&lt;P&gt;put y;&lt;/P&gt;&lt;P&gt;put z;&lt;/P&gt;&lt;P&gt;put m;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;&amp;nbsp;&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Scenario 2: how to round of columns of an incoming data set&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data roundtest; &amp;nbsp;&lt;/P&gt;&lt;P&gt;set &amp;lt;libref&amp;gt;.filename;&lt;/P&gt;&lt;P&gt;then how to write the code for rounding of columns&amp;nbsp;y w r l and k. &lt;U&gt;&lt;STRONG&gt;(Attached screen shot of columns)&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;the data comprises of columns y w r l and K and year. Now all these columns(except year) are in 8-9th decimal place. I want to round of to the first decimal&amp;nbsp;&amp;nbsp;place?...&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12188iDAA2CCF28C9E73B3/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Incoming data file_to be rounded down.PNG" title="Incoming data file_to be rounded down.PNG" /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12189i7DDD2D8160A8C7E7/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Incoming data file_to be rounded down.PNG" title="Incoming data file_to be rounded down.PNG" /&gt;</description>
      <pubDate>Thu, 14 Jan 2016 16:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243505#M55943</guid>
      <dc:creator>bgs</dc:creator>
      <dc:date>2016-01-14T16:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243506#M55944</link>
      <description>&lt;P&gt;You seem to have already answered your own question there:&lt;/P&gt;
&lt;P&gt;data roundtest; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set &amp;lt;libref&amp;gt;.filename;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; y=round(y,0.1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; w=round(w,0.1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; ...;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 16:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243506#M55944</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-14T16:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243509#M55945</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Appreciate your help. Expected something more complicated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LOL. Starting troubles &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 16:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243509#M55945</guid>
      <dc:creator>bgs</dc:creator>
      <dc:date>2016-01-14T16:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243510#M55946</link>
      <description>&lt;P&gt;To me, the most important piece of advice is not to round unless you absolutely have to.&amp;nbsp; You can control how many decimal places to use when printing by applying a format.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;x=123.4567;&lt;/P&gt;
&lt;P&gt;y=x;&lt;/P&gt;
&lt;P&gt;z=x;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=test;&lt;/P&gt;
&lt;P&gt;format y 8.1;&lt;/P&gt;
&lt;P&gt;format z 8.2;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can let variables keep their actual value without rounding, but still print rounded versions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 16:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243510#M55946</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-14T16:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243514#M55948</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&amp;nbsp;- Thank you. Yes I agree with you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please guide me on this:&lt;/P&gt;&lt;P&gt;You have used 8.1 and 8.2 - this is new to me, as in I was not aware&amp;nbsp;there were number formats like 8.1...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do i learn short cuts like that - as in can you share a link or something or am i approaching this the right way?&lt;/P&gt;&lt;P&gt;Hope my question makes sense!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 17:04:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243514#M55948</guid>
      <dc:creator>bgs</dc:creator>
      <dc:date>2016-01-14T17:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243515#M55949</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&amp;nbsp;or if i were to rephrase my earlier question&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you also explain (lead to to the explanation link) how this works?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As in if i use format 1.1 or 2.1 or ......8.1.... etc&lt;/P&gt;&lt;P&gt;What is the difference or what is the logis used by sas to apply these formats onto the dataset?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 17:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243515#M55949</guid>
      <dc:creator>bgs</dc:creator>
      <dc:date>2016-01-14T17:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243519#M55950</link>
      <description>&lt;P&gt;The "logic" for applying formats depends on what you are doing. Many analysis procedures will have a default to display a given number of decimals but you can direct the output to a data set and print the results with a different number of decimals, or you may be able to override the default. Here is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=sashelp.class;
   class sex;
   var height weight;
   table sex, (height weight)*(n mean std)
          /box='Default formats for statistics';
   table sex, (height weight)*(n mean*f=f8.4 std*f=best12.)
          /box='Specified formats for statistics';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can also use formats to group data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc freq data=sashelp.class;
   tables weight;
run;

proc format library=work;
   value WeightGroup
   0 - 85   = ' 0 &amp;lt;= 85'
   85&amp;lt; - 110= '85 &amp;lt;=110'
   110&amp;lt; - high='110&amp;gt;';
run;

Proc freq data=sashelp.class;
   tables weight;
   format weight WeightGroup.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 18:44:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243519#M55950</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-01-14T18:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243529#M55951</link>
      <description>&lt;P&gt;There are dozens of numeric formats available within the software.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It isn't a question of explaining a few tricks.&amp;nbsp; Formatting is one of the basics.&amp;nbsp; Just start somewhere, and add to what you know over time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To explain 8.1 and 8.2, here are a few general rules.&amp;nbsp; The first number ("8" in this case) refers to the total number of positions being used to print a numerical value.&amp;nbsp; That includes all digits (whether before or after the decimal point), the decimal point, and (if needed) a negative sign.&amp;nbsp; If you are using other numeric formats, such as those that print a dollar sign or a comma, the first number still includes every character being printed.&amp;nbsp; The second number ("1" or "2" in this case) is the number of digits to print after the decimal point.&amp;nbsp; SAS will automatically round as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you apply a format when reporting, it does not change the data.&amp;nbsp; It only changes the form in which that report prints the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 17:55:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243529#M55951</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-14T17:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243537#M55952</link>
      <description>ok that makes sense. Drawing on the same - explanation iv read/understood from u and elsewhere is that numbers are stored in 8 bytes of data hence the 8 and then 1.2.... after the decimal for round off accordingly.</description>
      <pubDate>Thu, 14 Jan 2016 18:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243537#M55952</guid>
      <dc:creator>bgs</dc:creator>
      <dc:date>2016-01-14T18:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243538#M55953</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;.&lt;BR /&gt;the second code I Understood. First one I have to disect and try out and then ill reach out to you.</description>
      <pubDate>Thu, 14 Jan 2016 18:15:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243538#M55953</guid>
      <dc:creator>bgs</dc:creator>
      <dc:date>2016-01-14T18:15:45Z</dc:date>
    </item>
    <item>
      <title>Re: Query on Rounding off</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243539#M55954</link>
      <description>&lt;P&gt;Truthfully, it's just coincidence that numbers are stored in 8 bytes.&amp;nbsp; SAS stores the value (not the digits themselves) in a totally different form (binary floating point).&amp;nbsp; SAS can accurately store an integer with 15 to 16 significant digits (depends on the operating system).&amp;nbsp; Very similar explanations would apply to other numeric formats (whether longer or shorter):&amp;nbsp; comma14.2, dollar5.0, for example.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2016 18:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Query-on-Rounding-off/m-p/243539#M55954</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-14T18:17:53Z</dc:date>
    </item>
  </channel>
</rss>

