<?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: how to round decimals only if for decimals and leave whole digit as it is in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626185#M184655</link>
    <description>&lt;P&gt;You can use the &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003171706.htm" target="_self"&gt;bestd format&lt;/A&gt; like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input val;
format val bestd6.2;
datalines;
100
98
37.09876554
32.7653243
76
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Feb 2020 15:41:12 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2020-02-20T15:41:12Z</dc:date>
    <item>
      <title>how to round decimals only if for decimals and leave whole digit as it is</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626181#M184651</link>
      <description>&lt;P&gt;i have values as&lt;/P&gt;
&lt;P&gt;val&lt;/P&gt;
&lt;P&gt;100&lt;/P&gt;
&lt;P&gt;98&lt;/P&gt;
&lt;P&gt;37.09876554&lt;/P&gt;
&lt;P&gt;32.7653243&lt;/P&gt;
&lt;P&gt;76&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and i want to have length as 5.2 only if i have integer and i use val1=input(val,best4.) but somehow it gives blank whenevr i have whole digits such as 100, 98, 76 and makes the deimals 37.09.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there anyway where i can keep whole digits as it is reduce decimals?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 15:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626181#M184651</guid>
      <dc:creator>noda6003</dc:creator>
      <dc:date>2020-02-20T15:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to round decimals only if for decimals and leave whole digit as it is</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626182#M184652</link>
      <description>&lt;P&gt;I'm not sure I understand this. You want to display integers without decimals and non-integers with two decimals, or?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 15:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626182#M184652</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-20T15:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to round decimals only if for decimals and leave whole digit as it is</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626183#M184653</link>
      <description>&lt;P&gt;yes, integers without decimals and non-integers with 2 decimals&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 15:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626183#M184653</guid>
      <dc:creator>noda6003</dc:creator>
      <dc:date>2020-02-20T15:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to round decimals only if for decimals and leave whole digit as it is</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626185#M184655</link>
      <description>&lt;P&gt;You can use the &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003171706.htm" target="_self"&gt;bestd format&lt;/A&gt; like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input val;
format val bestd6.2;
datalines;
100
98
37.09876554
32.7653243
76
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Feb 2020 15:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626185#M184655</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-20T15:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to round decimals only if for decimals and leave whole digit as it is</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626186#M184656</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input Var;
	datalines;
	100
	98
	37.0834224
	32.766523
	76
	;
run;

data want;
	set have;
	if find(Var, '.', '') ge 1 then Test = round(var,.1);
	else Test = Var;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Feb 2020 15:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626186#M184656</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2020-02-20T15:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to round decimals only if for decimals and leave whole digit as it is</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626196#M184657</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Internally, as SAS &lt;U&gt;&lt;STRONG&gt;stores&lt;/STRONG&gt; &lt;/U&gt;the data, whether or not there are decimals doesn't make a difference. The only place it makes a difference is in the &lt;U&gt;&lt;STRONG&gt;display&lt;/STRONG&gt; &lt;/U&gt;of the values, such as in a report. PROC PRINT won't allow a different format for every variable value -- unless you convert your number to a character string. However, PROC REPORT will allow you to use a different format for different values in a column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; For example, consider the program and output below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diff_fmt_proc_report.png" style="width: 545px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36271i1F46BE08EA15365D/image-size/large?v=v2&amp;amp;px=999" role="button" title="diff_fmt_proc_report.png" alt="diff_fmt_proc_report.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "helper" variable TESTDEC is being used as a simple way to tell whether the number needs decimal places in the format or not.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="use_testdec.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36272i90B8B65CAF245860/image-size/large?v=v2&amp;amp;px=999" role="button" title="use_testdec.png" alt="use_testdec.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;CALL DEFINE with PROC REPORT allows you to apply a format conditionally to a data cell. CALL DEFINE can only be used in a COMPUTE block, as shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps point you in a direction,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Feb 2020 16:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-round-decimals-only-if-for-decimals-and-leave-whole-digit/m-p/626196#M184657</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2020-02-20T16:12:58Z</dc:date>
    </item>
  </channel>
</rss>

