BookmarkSubscribeRSS Feed
jlin4
Fluorite | Level 6

Hi, I would like to seek some advice regarding proc tabulate. Using the heart dataset as an example, say that for whatever reason, I am interested in finding out the value of 2*mean of systolic of each group (systolic is a continuous variable) after classifying each row in the dataset according to 2 categorical columns (sex and weight_status). The codes below are wrong, but is there an elegant way to do such tabulation using proc tabulate? Or generally, is there a way to customise more complex computations using systolic, apart from computing its mean, median, min, max, etc. Thank you!

 

proc tabulate data=sashelp.heart;
	class sex weight_status;
	var systolic;
	table sex, weight_status*systolic*(mean*2);
run;

 

2 REPLIES 2
PhilC
Rhodochrosite | Level 12

The asterisk symbol used in the TABLES statement does not denote multiplication.  That's probably one of the more difficult hurdles one has to leap when learning this. 

ods select none;
proc tabulate data=sashelp.heart 
              out =have(drop=_:);
	class sex weight_status;
	var systolic;
	table sex, weight_status*systolic*(mean) /;
run;
ods select all;

data want;
 set have;
 double_Systolic_Mean=2*Systolic_Mean;
run;
ballardw
Super User

For this type of problem the approach would be:

1) summarize the data by the desired groups to get the mean for the groups (Proc summary is easy)

2) use a data step to multiply that mean by 2 for each group

3) Print or Proc Report to display the values.

 

Proc Tabulate does not let you calculations internally with the resulting statistics or cross statistics.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 460 views
  • 2 likes
  • 3 in conversation