<?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 using  &amp;quot;ALL&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/876247#M346213</link>
    <description>&lt;P&gt;With tabulate doing the calculations the only way not to have the other variables "summed" is to exclude them from the table:&lt;/P&gt;
&lt;PRE&gt;table  make=' ' * (cylinders='cylinders' )  
         cylinders='cylinders'*all='Totals per country' , 
        (sum=' '* type=''*origin=' ') sum=''*all='Totals cylinders per make' 
       / row=float nocontinued indent=1 rts=2  misstext=[label=" " ]    
        box=[label=' '] ;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 17 May 2023 14:58:48 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-05-17T14:58:48Z</dc:date>
    <item>
      <title>Proc tabulate using  "ALL"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875771#M346041</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if I have this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=mydata format=6.0 style=[font_size=5pt just=c fontstyle=italic borderwidth=0 cellpadding=0 foreground=dimgray];
class var1 var2 var3 / order=data style=[textalign=center ] missing;
  classlev var1 var2 var3 / style=[background=white font_weight=bold font_size=5pt foreground=dimgray cellpadding=2];
   var  Num_of_cases total_cases percentage /style=[background=white font_weight=bold font_size=5pt foreground=dimgray];
   keyword all sum  /style=[background=white font_weight=bold font_size=5pt foreground=dimgray];

  table ( var1=' '*([style=[background=white foreground=dimgray font_weight=bold font_size=5pt]]) &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;all='Totals per line'&lt;/STRONG&gt;&lt;/FONT&gt;)*
 (&lt;FONT color="#0000FF"&gt;num_of_cases='Number of cases' total_cases='sum of all cases' percentage='Percentages'*f=percent8.2&lt;/FONT&gt;) , 
   (sum=' '* var2=''*var3=' ')  / row=float nocontinued indent=1 rts=2  misstext=[label=" " ] 
   style=[cellpadding=3 font_size=5pt foreground=dimgray] 
   box=[label=' ' style=[background=white foreground=dimgray font_weight=bold font_size=5pt ]];
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If I use the "&lt;FONT color="#FF0000"&gt;All=Totals per line&lt;/FONT&gt;" statement, I get the sum totals of all these three variables:&lt;FONT color="#0000FF"&gt; num_of_cases, total_cases and percentage&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;at the bottom of the table. But I only need the sum totals of num_of_cases. Please help&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 09:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875771#M346041</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2023-05-15T09:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate using  "ALL"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875780#M346045</link>
      <description>&lt;P&gt;Share some example data so we could test your code and help...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what you shown my best guess would be to do something like:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data = sashelp.cars;
  class origin cylinders;
  var invoice mpg_city;
  table (cylinders="Cylinder Inv." all="Tot. Inv.")*invoice=" "*sum=" "*f=dollar15.2 
         cylinders="Cylinder MPG"*mpg_city=" "*sum=" "
        ,origin
        / row=float
        ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 09:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875780#M346045</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-15T09:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate using  "ALL"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875797#M346056</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;: &lt;/STRONG&gt;using sashelp.cars as a sample data. I only want to output the totals per country only for the cylinders(at the bottom)&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=sashelp.cars format=6.0 style=[font_size=5pt just=c fontstyle=italic borderwidth=0 cellpadding=0 foreground=dimgray];
class make type origin / order=data style=[textalign=center ] missing;
  classlev make type origin / style=[background=white font_weight=bold font_size=5pt foreground=dimgray cellpadding=2];
   var  cylinders horsepower MSRP /style=[background=white font_weight=bold font_size=5pt foreground=dimgray];
   keyword all sum  /style=[background=white font_weight=bold font_size=5pt foreground=dimgray];

  table ( make=' '*([style=[background=white foreground=dimgray font_weight=bold font_size=5pt]]) all='Totals per country')*
 (cylinders='cylinders' horsepower='horsepower' msrp='msrp') , 
   (sum=' '* type=''*origin=' ')  / row=float nocontinued indent=1 rts=2  misstext=[label=" " ] 
   style=[cellpadding=3 font_size=5pt foreground=dimgray] 
   box=[label=' ' style=[background=white foreground=dimgray font_weight=bold font_size=5pt ]];
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 May 2023 12:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875797#M346056</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2023-05-15T12:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate using  "ALL"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875821#M346063</link>
      <description>&lt;P&gt;Suggestion: Unless your question relates to actual use of style overrides and cell appearance for questions on the forum drop out all the appearances stuff as it just makes it hard to read the actual details related to the code submitted:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you are looking for this:&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=mydata ;
   class var1 var2 var3 / order=data  missing;
   var  Num_of_cases total_cases percentage /;
   keyword all sum  /;

  table  var1=' ' *      (num_of_cases='Number of cases' total_cases='sum of all cases' percentage='Percentages'*f=percent8.2) 
         All='Totals per line'*num_of_cases='Number of cases' , 
        (sum=' '* var2=''*var3=' ')  
       / row=float nocontinued indent=1 rts=2  misstext=[label=" " ]    
        box=[label=' '] ;
run;
&lt;/PRE&gt;
&lt;P&gt;When you use () to group things like (var1 all) *( thisvar thatvar anothervar) you forces both VAR1 and ALL to use the variables in the second (). Separate out the All and just use * with the desired variable(s).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 15:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875821#M346063</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-16T15:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate using  "ALL"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875858#M346078</link>
      <description>&lt;P&gt;I guess something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=sashelp.cars format=6.0 style=[font_size=5pt just=c fontstyle=italic borderwidth=0 cellpadding=0 foreground=dimgray];
class make type origin / order=data style=[textalign=center ] missing;
  classlev make type origin / style=[background=white font_weight=bold font_size=5pt foreground=dimgray cellpadding=2];
   var  cylinders horsepower MSRP /style=[background=white font_weight=bold font_size=5pt foreground=dimgray];
   keyword all sum  /style=[background=white font_weight=bold font_size=5pt foreground=dimgray];

  table ( make=' '*([style=[background=white foreground=dimgray font_weight=bold font_size=5pt]]) /*all='Totals per country'*/ )*
 (cylinders='cylinders' horsepower='horsepower' msrp='msrp') 
  cylinders='cylinders'*all='Totals per country' /* &amp;lt;- new code */, 
   (sum=' '* type=''*origin=' ')  / row=float nocontinued indent=1 rts=2  misstext=[label=" " ] 
   style=[cellpadding=3 font_size=5pt foreground=dimgray] 
   box=[label=' ' style=[background=white foreground=dimgray font_weight=bold font_size=5pt ]];
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 17:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/875858#M346078</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-05-15T17:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate using  "ALL"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/876034#M346132</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thankyou for that, that is what I wanted.&lt;/P&gt;
&lt;P&gt;Just one more question, if I want to do row sums without the percentage rows. How does this work.&lt;/P&gt;
&lt;P&gt;I tried but am not getting it. The percentage row are directly below the absolute values(rows)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 15:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/876034#M346132</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2023-05-16T15:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate using  "ALL"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/876057#M346146</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/168930"&gt;@Anita_n&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;Thankyou for that, that is what I wanted.&lt;/P&gt;
&lt;P&gt;Just one more question, if I want to do row sums without the percentage rows. How does this work.&lt;/P&gt;
&lt;P&gt;I tried but am not getting it. The percentage row are directly below the absolute values(rows)&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would have to see a bit of a worked example of exactly what you expect. Any ALL in the Column dimension is going to cross with everything in the rows. If the information is more important than having everything in a single table I would suggest a second Table statement (tabulate can have multiple tables created in one pass with the same Class and Var variables). Just leave out the bits you don't want in another table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the intent is to have a single table of a very specific structure you may need to consider either different data structure or perhaps look at a different procedure such as Proc Report (though report doesn't like multiple statistics in a single column) or both more data manipulation/summarizing before creating the report document and different report code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One of the concerns I had when I read your code was the presence of a variable named Percentage in the first place. Summing or most statistics on a pre-calculated percentage value are either misleading, subject to misunderstanding or incorrect.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide a small example data set and what you are attempting to get with that data?&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 17:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/876057#M346146</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-16T17:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate using  "ALL"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/876168#M346197</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;: This is what I actually want : on the right handside I wish to calculate the sum totals per make only for cylinders and not for horsepower and mrsp&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=sashelp.cars ;
   class make type origin  / order=data  missing;
   var  cylinders horsepower MSRP /;
   keyword all sum  /;

  table  make=' ' *      (cylinders='cylinders' horsepower='horsepower' msrp='msrp')  
         cylinders='cylinders'*all='Totals per country' , 
        (sum=' '* type=''*origin=' ') sum=''*all='Totals cylinders per make' 
       / row=float nocontinued indent=1 rts=2  misstext=[label=" " ]    
        box=[label=' '] ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 May 2023 06:38:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/876168#M346197</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2023-05-17T06:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc tabulate using  "ALL"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/876247#M346213</link>
      <description>&lt;P&gt;With tabulate doing the calculations the only way not to have the other variables "summed" is to exclude them from the table:&lt;/P&gt;
&lt;PRE&gt;table  make=' ' * (cylinders='cylinders' )  
         cylinders='cylinders'*all='Totals per country' , 
        (sum=' '* type=''*origin=' ') sum=''*all='Totals cylinders per make' 
       / row=float nocontinued indent=1 rts=2  misstext=[label=" " ]    
        box=[label=' '] ;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2023 14:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-tabulate-using-quot-ALL-quot/m-p/876247#M346213</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-17T14:58:48Z</dc:date>
    </item>
  </channel>
</rss>

