BookmarkSubscribeRSS Feed
alr
Quartz | Level 8 alr
Quartz | Level 8

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

4 REPLIES 4
alr
Quartz | Level 8 alr
Quartz | Level 8

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;

Cynthia_sas
SAS Super FREQ

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

alr
Quartz | Level 8 alr
Quartz | Level 8

Thank you Cynthia.

Ksharp
Super User

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 8622 views
  • 4 likes
  • 3 in conversation