<?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: Show only nonzero decimals in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796702#M33003</link>
    <description>&lt;P&gt;Did you try the BEST format?&lt;/P&gt;
&lt;PRE&gt;1     data have;
2       input Count;
3       put count best12. ;
4     cards;

           1
           2
           5
         7.1
        6.52
           2
           3
&lt;/PRE&gt;</description>
    <pubDate>Wed, 16 Feb 2022 20:37:19 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-02-16T20:37:19Z</dc:date>
    <item>
      <title>Show only nonzero decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796697#M33000</link>
      <description>&lt;P&gt;I want to format my data so that decimals are only shown for non-whole numbers.&amp;nbsp; e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Count&lt;/P&gt;&lt;P&gt;1,000&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;578&lt;/P&gt;&lt;P&gt;7.1&lt;/P&gt;&lt;P&gt;67,253.52&lt;/P&gt;&lt;P&gt;22,000&lt;/P&gt;&lt;P&gt;3,211&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried playing with the commaw.d format, but that appends trailing zeros to every number depending on the value of d.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit:&lt;/P&gt;&lt;P&gt;A bit more context - my data is count/sum data grouped by a categorical variable, and while the vast majority of the rows are, by nature, whole numbers, some of the items can have decimal counts.&amp;nbsp; However, because the decimal items are so sparse, I'd rather not include decimals for every number since it's largely unnecessary and distracting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Adjusted example numbers to use commas.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 20:44:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796697#M33000</guid>
      <dc:creator>osbornejo</dc:creator>
      <dc:date>2022-02-16T20:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Show only nonzero decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796699#M33002</link>
      <description>&lt;P&gt;A little more context will help if finding the right solution for you.&amp;nbsp; &amp;nbsp;It does not really make much sense to not show the zeros if the numbers are all of the same type.&amp;nbsp; But if the values in that variable are really from different things and you have some other variable that indicates which type they are then you could use that to help you create a text value that looks the way you want.&amp;nbsp; Or perhaps with PROC REPORT produce a report that looks like you want from the existing numeric variable.&lt;/P&gt;
&lt;P&gt;If you do not already have something to tell you which style to display the number then test if the COUNT is an integer or not and then generate the new character variable based on that test.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
   length string $10.;
   if count=int(count) then string=put(count,7.);
   else count=put(count,10.2);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Feb 2022 20:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796699#M33002</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-16T20:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Show only nonzero decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796702#M33003</link>
      <description>&lt;P&gt;Did you try the BEST format?&lt;/P&gt;
&lt;PRE&gt;1     data have;
2       input Count;
3       put count best12. ;
4     cards;

           1
           2
           5
         7.1
        6.52
           2
           3
&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Feb 2022 20:37:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796702#M33003</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-16T20:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: Show only nonzero decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796703#M33004</link>
      <description>See my edit for more context</description>
      <pubDate>Wed, 16 Feb 2022 20:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796703#M33004</guid>
      <dc:creator>osbornejo</dc:creator>
      <dc:date>2022-02-16T20:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Show only nonzero decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796705#M33005</link>
      <description>I didn't realize that BEST could format each row differently. However, I didn't use a very good example - some of my numbers are in the thousands, so I'd like to have commas.</description>
      <pubDate>Wed, 16 Feb 2022 20:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796705#M33005</guid>
      <dc:creator>osbornejo</dc:creator>
      <dc:date>2022-02-16T20:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Show only nonzero decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796709#M33006</link>
      <description>&lt;P&gt;I suggest you try a user-defined PICTURE format, using the BEST format for numbers less than 1,000 and create your own COMMA format for numbers 1,000 or greater.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 20:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796709#M33006</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-02-16T20:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Show only nonzero decimals</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796712#M33007</link>
      <description>&lt;P&gt;Don't really understand how you can have some values with fractions and the rest as whole numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the fractional values only appear in small values then you could use a custom format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value commad 
  0&amp;lt;-&amp;lt;1
 ,1&amp;lt;-&amp;lt;2
 ,2&amp;lt;-&amp;lt;3
 ,3&amp;lt;-&amp;lt;4
 ,4&amp;lt;-&amp;lt;5
 ,5&amp;lt;-&amp;lt;6
 ,6&amp;lt;-&amp;lt;7
 ,7&amp;lt;-&amp;lt;8
 ,8&amp;lt;-&amp;lt;9
 ,9&amp;lt;-&amp;lt;10
  = [10.2]
  other = [comma10.]
;
run;

data test;
  input count :comma.;
  put count commad.;
cards;
1,000
2
578
7.1
67,253.52
22,000
3,211
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But that would get a little large if you wanted support values like&amp;nbsp;67,253.52.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise just generate text.&lt;/P&gt;
&lt;PRE&gt;175   data test;
176     input count :comma.;
177     string = put(count,comma10.2);
178     string = tranwrd(string,'.00',' ');
179     put count comma10.2 +1 string ;
180   cards;

  1,000.00 1,000
      2.00 2
    578.00 578
      7.10 7.10
 67,253.52 67,253.52
 22,000.00 22,000
  3,211.00 3,211
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Feb 2022 21:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Show-only-nonzero-decimals/m-p/796712#M33007</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-16T21:13:14Z</dc:date>
    </item>
  </channel>
</rss>

