<?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: proc tabulate-overlapping ranges,Show missing groups,display PCT with % symbol in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-overlapping-ranges-Show-missing-groups-display-PCT/m-p/606029#M175930</link>
    <description>&lt;P&gt;2-Show also missing groups (in this example: for group '9-10' need to show it too with zero values)&lt;/P&gt;
&lt;P&gt;See option &lt;FONT face="courier new,courier"&gt;classdata=&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3-columns 'PCT_Customers' and ' PCT_Sum_Y' will be displayed with % symbol&lt;/P&gt;
&lt;P&gt;Something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Y=' '*PCTsum='PCT_Sum_Y'*f=percent9.2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Nov 2019 07:25:36 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2019-11-21T07:25:36Z</dc:date>
    <item>
      <title>proc tabulate-overlapping ranges,Show missing groups,display PCT with % symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-overlapping-ranges-Show-missing-groups-display-PCT/m-p/606025#M175927</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to calculate summary statistics using proc tabulate.&lt;/P&gt;
&lt;P&gt;I have 3 requests:&lt;/P&gt;
&lt;P&gt;1-Using overlapping formats values (&lt;EM&gt;overlapping&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;ranges)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;2-Show also&amp;nbsp; missing groups (in this example:&amp;nbsp; for group&amp;nbsp;'9-10'&amp;nbsp; need to show it too with zero values)&lt;/P&gt;
&lt;P&gt;3-columns 'PCT_Customers' and&amp;nbsp; &amp;nbsp;' PCT_Sum_Y'&amp;nbsp; &amp;nbsp;will be displayed with % symbol&lt;/P&gt;
&lt;P&gt;&amp;nbsp; columns&amp;nbsp; 'Sum_Y'&amp;nbsp; &amp;nbsp;and 'No_Customers'&amp;nbsp; &amp;nbsp;will be displayed with format&amp;nbsp;comma18.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From 3 requests I know how to do the 1st one.&lt;/P&gt;
&lt;P&gt;Please find the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ttbl;
input ID group Y;
cards;
1 3 10
2 4 15
3 3 20
4 4 25
5 5 30
6 8 35
7 11 40
8 7 45
9 11 50
10 3 55
;
run;

proc format;
value multiFmt (multilabel notsorted)
2,3='2-3'
4='4'
2-4='Total 2-4'
5-8='5-8'
9-10='9-10'
5-10='Total 5-10'
11='11'
low-high='Total All'
;
Run;


PROC TABULATE DATA=ttbl  OUT=output;
class group / mlf preloadfmt order=data ;
	VAR ID Y  ;
	TABLE group='' ,
                      ID=''*N='No_Customers' 
					  ID=''*PCTN='PCT_Customers' 
                      Y=''*sum='Sum_Y'
                      Y=''*PCTsum='PCT_Sum_Y'
;
format group multiFmt.;
RUN;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 07:01:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-overlapping-ranges-Show-missing-groups-display-PCT/m-p/606025#M175927</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2019-11-21T07:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate-overlapping ranges,Show missing groups,display PCT with % symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-overlapping-ranges-Show-missing-groups-display-PCT/m-p/606029#M175930</link>
      <description>&lt;P&gt;2-Show also missing groups (in this example: for group '9-10' need to show it too with zero values)&lt;/P&gt;
&lt;P&gt;See option &lt;FONT face="courier new,courier"&gt;classdata=&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3-columns 'PCT_Customers' and ' PCT_Sum_Y' will be displayed with % symbol&lt;/P&gt;
&lt;P&gt;Something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Y=' '*PCTsum='PCT_Sum_Y'*f=percent9.2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 07:25:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-overlapping-ranges-Show-missing-groups-display-PCT/m-p/606029#M175930</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-11-21T07:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate-overlapping ranges,Show missing groups,display PCT with % symbol</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-overlapping-ranges-Show-missing-groups-display-PCT/m-p/606219#M176015</link>
      <description>&lt;P&gt;You likely want the PRINTMISS table option to get the Preloadfmt to work as desired:&lt;/P&gt;
&lt;PRE&gt;PROC TABULATE DATA=work.ttbl  OUT=output;
class group / mlf preloadfmt order=data ;
	VAR ID Y  ;
	TABLE group='' ,
                      ID=''*N='No_Customers' 
					  ID=''*PCTN='PCT_Customers' 
                      Y=''*sum='Sum_Y'
                      Y=''*PCTsum='PCT_Sum_Y'
        /printmiss
;
format group multiFmt.;
RUN;&lt;/PRE&gt;
&lt;P&gt;If you want 0 to appear for the missing statistics associated with the that 9-10 row such as 0% you will need to create a custom format that displays missing that way. Since you are using the PCTSUM statistic you will also need to create custom format because a display with the PERCENTw.d format really expects a source value in decimal form such as .153 to display as 15.3% but PCTSum and the PCT statistics will have values already multiplied by 100 to look nice and would already be 15.3. Which with a Percent format applied would then be multiplied by 100 again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value multiFmt (multilabel notsorted)
2,3='2-3'
4='4'
2-4='Total 2-4'
5-8='5-8'
9-10='9-10'
5-10='Total 5-10'
11='11'
low-high='Total All'
;
value custcomma
.='0'
low-high = [Comma9.]
;
picture custperc
. = '0%' (noedit)
low-high = '009.99%';
Run;


PROC TABULATE DATA=work.ttbl  OUT=output;
class group / mlf preloadfmt order=data ;
	VAR ID Y  ;
	TABLE group='' ,
                      ID=''*N='No_Customers' 
					  ID=''*PCTN='PCT_Customers' 
                      Y=''*sum='Sum_Y' *f=custcomma.
                      Y=''*PCTsum='PCT_Sum_Y'*f=custperc.
        /printmiss  
;
format group multiFmt.;
RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is a table option MISSTEXT=' ' to show a specific given text for &lt;STRONG&gt;all&lt;/STRONG&gt; missing values. With a table only having counts then MISSTEXT='0' could be appropriate. With other statistics though that might not work, especially if you want a mix of 0 and 0%.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 23:30:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-overlapping-ranges-Show-missing-groups-display-PCT/m-p/606219#M176015</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-11-21T23:30:55Z</dc:date>
    </item>
  </channel>
</rss>

