Calcite | Level 5

## proc means

I am trying to do the proc means by day and treatment but I am not finding the right

 SubjectID day group variable1_Mean variable2_Mean variable3_Median variable3_Median 2 0 placebo 2 2 16 0 1 0 treatment 1 3 11 0 3 0 treatment 2 1 12 0 2 1 placebo 2 2 54 122 1 1 treatment 1 5 7 2.5 3 1 treatment 1 1 14.5 2 2 2 placebo . 1 . 0 1 2 treatment 2 1 12 3 3 2 treatment 2 1 14 4

Something like this:

 Day group variable1_Mean variable2_Mean variable3_Median variable3_Median 0 treatment 1.5 1 treatment 1 2 treatment 2 0 placebo 2 1 placebo 2 2 placebo

I did the following:

proc sort data= have; by day group;

run;

proc means data = have out = stat;

by day group;

var Variable1_Mean -- Variable3_Median

n= mean= lclm= uclm= median= min= max= nmiss=/autoname;

proc means data=have;

by day group;

var variable1_mean -- variable3_median;

output out=want n= mean= lclm= uclm= median= min= max= nmiss=/autoname;

run;

2 REPLIES 2
Meteorite | Level 14

## Re: proc means

In my understanding, you want to compute the mean for each variable by group and day (e.g the mean of the 3 median, the mean of the 3 individuals means, etc). Is that right ?

So there is no need to compute other statistics like median, etc.

``````proc sort data= have;
by group day ;
run;

proc means data=have mean noprint;
class group day ;
var variable1_Mean variable2_Mean variable3_Mean variable4_Median;
ways 2;
output out=want (drop=_type_ _freq_) mean= variable1_Mean variable2_Mean variable3_Mean variable4_Median;
run;
proc print;``````

Fluorite | Level 6

## Re: proc means

You can use the NWAY option for this. Note that Proc means or summary will not calculate means for missing values, so you have to exclude the missing value. I have taken variable1_mean and median, You can include all the other variable in the VAR statement and also in the Mean and Median statements for the output.

Please refer to the link below for more details on Proc means.

```data have;
input subject day group \$9. variable1_Mean;
datalines;
2 0 placebo   2
1 0 treatment 1
3 0 treatment 2
2 1 placebo   2
1 1 treatment 1
3 1 treatment 1
2 2 placebo   .
1 2 treatment 2
3 2 treatment 2
3 3 treatment 1
3 3 treatment 2
3 3 treatment 3
3 3 treatment 4

;
run;

proc summary data=have(WHERE=(variable1_Mean ^=.)) mean median nway;
class group day;
var variable1_Mean;
output out=want (drop=_type_ _freq_) mean=variable1_Mean
median=variable1_Median;
run;```
Subhro Kar
www.9to5sas.com
Discussion stats
• 2 replies
• 519 views
• 0 likes
• 3 in conversation