Reputation: 763
I have an example of a dataset in the following manner
data have;
input match percent;
cards;
0 34
0 54
0 33
0 23
1 60
1 70
1 70
1 70
;
Essentially I want to sum the observations that are associated with 0
and then divide them by the number of 0
s to find the average.
e.g 34+54+33+23/4 then do the same for 1
's
I looked at PROC TABULATE. However, I don't understand how to carry out this procedure.
Upvotes: 0
Views: 1002
Reputation: 1804
You can use proc means
and you will the mean plus a bunch of other stats:
more examples here for proc means
.
proc means data=have noprint;
by match;
output out=want ;
Output:
Upvotes: 1
Reputation: 1103
This can be done very easily using proc summary
or proc means
.
proc summary data=have nway missing;
class match;
var percent;
output out=want mean=;
run;
You can also output a variety of other statistics using these procedures.
Upvotes: 0
Reputation: 12465
Many ways to do this in SAS. I would use PROC SQL
proc sql noprint;
create table want as
select match,
mean(percent) as percent
from have
group by match;
quit;
Upvotes: 1