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?
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;
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
Thank you Cynthia.
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.