<?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 proc report-add 3 total columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report-add-3-total-columns/m-p/663131#M197906</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to add&amp;nbsp; 4 more total columns.&lt;/P&gt;
&lt;P&gt;Total Nr customers for&amp;nbsp; Z3=No&lt;/P&gt;
&lt;P&gt;Total Nr customers for&amp;nbsp; Z3=Yes&lt;/P&gt;
&lt;P&gt;Sum income&amp;nbsp; for&amp;nbsp; Z3=No&lt;BR /&gt;Sum income&amp;nbsp; for&amp;nbsp; Z3=Yes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am also happy to hear about any suggestion how to make the table better or display it better&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ttt;
input ID Z1 $ Z2 $ Z3 $ Z4 $ Y;
cards;
1 a express Yes Long 10
2 a express Yes Long 20
3 a express No Long 30
4 a Direct No Long 40
5 a Direct Yes Long 150
6 a Direct No Long 60	
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE style="line-height: 1.71429;"&gt;&lt;CODE class=" language-sas"&gt;7 a express Yes short 15
8 b express Yes short 25
9 b express No short 35
10 b Direct No short 45
11 b Direct Yes short 55
12 b Direct No short 65
;
run;
Proc tabulate data =ttt  format=comma21.;
Class z1  z2  z3  z4  ;
Var y;
Table z1=""*z2='',
z3='Nr customers'*z4=''*N='N'   all='income'*N='Grand total N'
z3='Sum Income'*z4=''*SUM=''*y='SUM'  all='Sum Income'*y='Grand total income'
/box='Z1/Z2' misstext='0'  nocellmerge;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jun 2020 12:00:54 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2020-06-18T12:00:54Z</dc:date>
    <item>
      <title>proc report-add 3 total columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-add-3-total-columns/m-p/663131#M197906</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to add&amp;nbsp; 4 more total columns.&lt;/P&gt;
&lt;P&gt;Total Nr customers for&amp;nbsp; Z3=No&lt;/P&gt;
&lt;P&gt;Total Nr customers for&amp;nbsp; Z3=Yes&lt;/P&gt;
&lt;P&gt;Sum income&amp;nbsp; for&amp;nbsp; Z3=No&lt;BR /&gt;Sum income&amp;nbsp; for&amp;nbsp; Z3=Yes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am also happy to hear about any suggestion how to make the table better or display it better&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ttt;
input ID Z1 $ Z2 $ Z3 $ Z4 $ Y;
cards;
1 a express Yes Long 10
2 a express Yes Long 20
3 a express No Long 30
4 a Direct No Long 40
5 a Direct Yes Long 150
6 a Direct No Long 60	
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE style="line-height: 1.71429;"&gt;&lt;CODE class=" language-sas"&gt;7 a express Yes short 15
8 b express Yes short 25
9 b express No short 35
10 b Direct No short 45
11 b Direct Yes short 55
12 b Direct No short 65
;
run;
Proc tabulate data =ttt  format=comma21.;
Class z1  z2  z3  z4  ;
Var y;
Table z1=""*z2='',
z3='Nr customers'*z4=''*N='N'   all='income'*N='Grand total N'
z3='Sum Income'*z4=''*SUM=''*y='SUM'  all='Sum Income'*y='Grand total income'
/box='Z1/Z2' misstext='0'  nocellmerge;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 12:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-add-3-total-columns/m-p/663131#M197906</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-06-18T12:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc report-add 3 total columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-add-3-total-columns/m-p/663145#M197911</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What if you add the following code to the TABLES statement?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	Table z1=""*z2='' all, /*added:all*/
		z3='Nr customers'*z4*N
		all='income'*N='Grand total N'
		z3='Sum Income'*z4*y
		all='Sum Income'*y='Grand total income'
		z3*N /*added*/
		z3*y&amp;nbsp;/*added*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 12:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-add-3-total-columns/m-p/663145#M197911</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-06-18T12:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: proc report-add 3 total columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-add-3-total-columns/m-p/663178#M197917</link>
      <description>&lt;P&gt;One way&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc tabulate data =ttt  format=comma21.;
   Class z1  z2  z3  z4  ;
   Var y;
   Table z1=""*z2='',
         z3='Nr customers'*(z4='' All)*N='N'   
         all='income'*N='Grand total N'
         z3='Sum Income'* (z4='' All)*SUM=''*y='SUM'  
         all='Sum Income'*y='Grand total income'
   /box='Z1/Z2' misstext='0'  nocellmerge;
Run;&lt;/PRE&gt;
&lt;P&gt;When you want&amp;nbsp; an "all" for each level of a class variable then typically you go to the next level nested variable for the All.&amp;nbsp; So&amp;nbsp;&amp;nbsp; Z3 *(Z4 All)&amp;nbsp; gets the summary for all levels of Z4 within each level of Z3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Personally since you have provided reasonable column headings indicating Number of Customers and Total Income I would suppress the statistic label unless you intend to add another statistic like "mean income" within each level of Z4&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2020 14:09:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-add-3-total-columns/m-p/663178#M197917</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-18T14:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc report-add 3 total columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-add-3-total-columns/m-p/663794#M198228</link>
      <description>&lt;P&gt;Thank you so much!!&lt;/P&gt;
&lt;P&gt;I have a&amp;nbsp; question please regarding the great code that you provided:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;1-Column "Grand Total N " has one column header&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Column &amp;nbsp;"Grand Total sum income" has 2 columns headers : "Grand Total sum income" and below of it&amp;nbsp; "SUM".&lt;/P&gt;
&lt;P&gt;What is the way that both columns will have same number of headers?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc tabulate data =ttt  format=comma21.;
   Class z1  z2  z3  z4  ;
   Var y;
   Table z1=""*z2='',
         z3='Nr customers'*(z4='' All)*N='N'   
         all=''*N='Grand total N'
         z3='Sum Income'* (z4='' All)*SUM=''*y='SUM'  
         all=''*y='Grand total sum income'
   /box='Z1/Z2' misstext='0'  nocellmerge;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jun 2020 05:09:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-add-3-total-columns/m-p/663794#M198228</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-06-21T05:09:02Z</dc:date>
    </item>
  </channel>
</rss>

