<?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: Display percentage of Grand total per column in Proc Report in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744369#M233203</link>
    <description>&lt;PRE&gt;data shoes;
set sashelp.shoes;
if region in ('Africa', 'Asia','Canada')
and product in ('Sandal','Slipper');
run;

proc format;
picture fmt
low-high='009.99%'
;
run;
proc tabulate data=shoes;
class region product;
var sales;
tables product*sum all all*pctsum*f=fmt.,
       sales*region sales*all;
	run;&lt;/PRE&gt;
&lt;P&gt;OK. I know how to make it happen.&lt;/P&gt;</description>
    <pubDate>Fri, 28 May 2021 12:05:02 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-05-28T12:05:02Z</dc:date>
    <item>
      <title>Display percentage of Grand total per column in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/743938#M233007</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data shoes;
set sashelp.shoes;
if region in ('Africa', 'Asia','Canada')
and product in ('Sandal','Slipper');
run;


proc report data=shoes nowd;
column Product Region, sales;
define product/group;
define region/across;
define sales/'sales in USD';
rbreak after/summarize;
compute after;
Product = 'Grand Total';
endcomp;
run;&lt;BR /&gt; &lt;/PRE&gt;
&lt;TABLE width="266"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="74"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD colspan="3" width="192"&gt;Region&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="74"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;Africa&lt;/TD&gt;
&lt;TD width="64"&gt;Asia&lt;/TD&gt;
&lt;TD width="64"&gt;Canada&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="74"&gt;Product&lt;/TD&gt;
&lt;TD width="64"&gt;sales in USD&lt;/TD&gt;
&lt;TD width="64"&gt;sales in USD&lt;/TD&gt;
&lt;TD width="64"&gt;sales in USD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Sandal&lt;/TD&gt;
&lt;TD&gt;$190,409&lt;/TD&gt;
&lt;TD&gt;$8,208&lt;/TD&gt;
&lt;TD&gt;$14,798&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Slipper&lt;/TD&gt;
&lt;TD&gt;$337,076&lt;/TD&gt;
&lt;TD&gt;$152,032&lt;/TD&gt;
&lt;TD&gt;$952,751&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Grand Total&lt;/TD&gt;
&lt;TD&gt;$527,485&lt;/TD&gt;
&lt;TD&gt;$160,240&lt;/TD&gt;
&lt;TD&gt;$967,549&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to dsiplay the percentage of the grand total at the bottom just undeneath of Grand Total such as this&lt;/P&gt;
&lt;TABLE width="266"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="74"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD colspan="3" width="192"&gt;Region&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="74"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="64"&gt;Africa&lt;/TD&gt;
&lt;TD width="64"&gt;Asia&lt;/TD&gt;
&lt;TD width="64"&gt;Canada&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="74"&gt;Product&lt;/TD&gt;
&lt;TD width="64"&gt;sales in USD&lt;/TD&gt;
&lt;TD width="64"&gt;sales in USD&lt;/TD&gt;
&lt;TD width="64"&gt;sales in USD&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Sandal&lt;/TD&gt;
&lt;TD&gt;$190,409&lt;/TD&gt;
&lt;TD&gt;$8,208&lt;/TD&gt;
&lt;TD&gt;$14,798&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Slipper&lt;/TD&gt;
&lt;TD&gt;$337,076&lt;/TD&gt;
&lt;TD&gt;$152,032&lt;/TD&gt;
&lt;TD&gt;$952,751&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Grand Total&lt;/TD&gt;
&lt;TD&gt;$527,485&lt;/TD&gt;
&lt;TD&gt;$160,240&lt;/TD&gt;
&lt;TD&gt;$967,549&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;Africa Pct&lt;/TD&gt;
&lt;TD&gt;Asia Pct&lt;/TD&gt;
&lt;TD&gt;Canada Pct&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;36.10%&lt;/TD&gt;
&lt;TD&gt;5.12%&lt;/TD&gt;
&lt;TD&gt;1.53%&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 26 May 2021 16:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/743938#M233007</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-05-26T16:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Display percentage of Grand total per column in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/743984#M233015</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm confused by your percents. When I do the math with my calculator based on grand total of&amp;nbsp;$1,655,274 , here's what I get:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1622050248520.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59781i5E9701780C20E1A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1622050248520.png" alt="Cynthia_sas_0-1622050248520.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; This is probably easier to do in TABULATE, where you can generate ROWPCTSUM and COLPCTSUM more easily. PROC REPORT would only do the equivalent of the column percent and you'd need to fiddle to get an extra line underneath the grand total line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; How did you calculate the percents in your example?&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 18:12:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/743984#M233015</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-05-26T18:12:28Z</dc:date>
    </item>
    <item>
      <title>Re: Display percentage of Grand total per column in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744135#M233075</link>
      <description>&lt;P&gt;Proc report is unable to do. But PROC SQL could.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data shoes;
set sashelp.shoes;
if region in ('Africa', 'Asia','Canada')
and product in ('Sandal','Slipper');
run;

proc sql;
create table want as
select 1 as id, product,region,put(sum(sales),dollar32. -l) as sales length=80
 from shoes
  group by product,region
union all
select 2 ,'Grand Total',region,put(sum(sales),dollar32. -l) as sales
 from shoes
  group by region
union all
select 3,'Percent',region,put(sum(sales)/(select sum(sales) from shoes),percent8.2 -l)
 from shoes
  group by region
;
quit;
proc report data=want nowd;
columns id product sales,region;
define id/group noprint;
define product/group;
define region/across;
define sales/group ' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 388px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59810iAD669E4D6CE2FDE3/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 13:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744135#M233075</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-27T13:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Display percentage of Grand total per column in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744220#M233133</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; PROC REPORT can do this in a COMPUTE block:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1622132230594.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59814iDDE5DC74626B290B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1622132230594.png" alt="Cynthia_sas_0-1622132230594.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it is easier to do in PROC TABULATE:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1622132291315.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/59815i6CF02A861EF14BF5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1622132291315.png" alt="Cynthia_sas_1-1622132291315.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it is do-able in PROC REPORT. It would take a bit more modification to "pretty up" both the REPORT and the TABULATE output. Probably another COMPUTE block if you want the percent underneath the totals in the REPORT output. But TABULATE can give you that with the procedure syntax, which is why I'd choose TABULATE for this one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Thu, 27 May 2021 16:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744220#M233133</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-05-27T16:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Display percentage of Grand total per column in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744367#M233202</link>
      <description>Cynthia,&lt;BR /&gt;How to make percent format is  xx.xx% . I tried  " all*pctsum*f=percent8.2, " , but can't get job done .</description>
      <pubDate>Fri, 28 May 2021 12:02:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744367#M233202</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-28T12:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Display percentage of Grand total per column in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744369#M233203</link>
      <description>&lt;PRE&gt;data shoes;
set sashelp.shoes;
if region in ('Africa', 'Asia','Canada')
and product in ('Sandal','Slipper');
run;

proc format;
picture fmt
low-high='009.99%'
;
run;
proc tabulate data=shoes;
class region product;
var sales;
tables product*sum all all*pctsum*f=fmt.,
       sales*region sales*all;
	run;&lt;/PRE&gt;
&lt;P&gt;OK. I know how to make it happen.&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 12:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744369#M233203</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-28T12:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Display percentage of Grand total per column in Proc Report</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744421#M233223</link>
      <description>Hi:&lt;BR /&gt;  The reason you need a PICTURE format is that the PERCENT format does a multiply by 100. The issue with this and TABULATE is that TABULATE also does a multiply by 100 for the percent-based statistics. So you don't want the PERCENT format to do a second multiply. The PICTURE format allows you to add the % sign without doing the multiply by 100 for the percent with TABULATE.&lt;BR /&gt;Cynthia</description>
      <pubDate>Fri, 28 May 2021 14:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Display-percentage-of-Grand-total-per-column-in-Proc-Report/m-p/744421#M233223</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-05-28T14:29:56Z</dc:date>
    </item>
  </channel>
</rss>

