The SAS Output Delivery System and reporting techniques

Total sum in proc tabulate

Reply
Contributor alr
Contributor
Posts: 39

Total sum in proc tabulate

Hi,
I have a simple tabulate:


proc tabulate data=sashelp.class;
class name sex;
var age height weight;
table sex * name sex,
       (age height weight)*sum=' '
    ;
run;

But I’m not interested to get the sum of weight per sex in total. In my data it does not make sense to have a total sum for all of the variables.

Is it possible in proc tabulate or should I use another procedure?

tabulate.PNG

Contributor alr
Contributor
Posts: 39

Re: Total sum in proc tabulate

Off course a possibility is to call proc tabulate twice, but it is much better if I can get it in one table.


proc tabulate data=sashelp.class;
class name sex;
var age height weight;
table sex * name ,
       (age height weight)*sum=' '
    ;
table sex ,
       (age height)*sum=' '
    ;
run;

SAS Super FREQ
Posts: 8,645

Re: Total sum in proc tabulate

Hi:

  I would do a report like this with PROC REPORT instead of TABULATE. With TABULATE, once WEIGHT is on the table, the cell for WEIGHT will be "filled in" with a statistic unless you have a separate TABLE statement without WEIGHT, as you showed in your second post. I don't understand the point of showing the sum of AGE or the sum of HEIGHT, but since PROC REPORT can give you almost all the same statistics as TABULATE and since you can customize PROC REPORT to have a summary line for females and a summary line for males, you could generate the report you want (list of names, followed by summary lines) easier than with TABULATE. I believe there have been several forum postings on how to generate multiple summary lines with PROC REPORT.

cynthia

Contributor alr
Contributor
Posts: 39

Re: Total sum in proc tabulate

Thank you Cynthia.

Grand Advisor
Posts: 9,333

Re: Total sum in proc tabulate

It is a bad idea. I don't know if you like it. Actually it is just hiding them all .

proc format;
value fmt
 811,1089.5='white';
run;

ods html file='x.html' style=sasweb;
proc tabulate data=sashelp.class;
class name sex;
var age height weight;
table sex * name sex,
       (age height )*sum=' ' weight*sum=''*{style={foreground=fmt.}}
    ;
run;
ods html close;




Xia Keshan

Post a Question
Discussion Stats
  • 4 replies
  • 530 views
  • 4 likes
  • 3 in conversation