Hello,
Could you pls suggest me how can i get Overall mean and mean for scores by Gender using PROC SUMMARY. See the dataset and the output tables i want; I'm struggling to get the Overall Mean for Score1 and Score 2 according to Gender (Male, Female).
data Made;
ID | Gender | Score1 | Score2 |
101 | M | 10 | 8 |
102 | F | 9 | 12 |
103 | M | 7 | 5 |
104 | F | 5 | 8 |
output want;
Gender | All (mean) |
Score1 (mean) |
Score2 (mean) |
M | |||
F | |||
Total (mean) |
Thank you,
Akter
Hello,
Here you are:
data have;
input ID $ Gender $ Score1 Score2;
cards;
101 M 10 8
102 F 9 12
103 M 7 5
104 F 5 8
;
run;
PROC SUMMARY data=have;
CLASS Gender;
var Score: ;
output out=summary_want;
run;
PROC PRINT data=summary_want;
where _STAT_='MEAN';
run;
/* end of program */
Have a nice Sunday evening!
Koen
Hello,
Here you are:
data have;
input ID $ Gender $ Score1 Score2;
cards;
101 M 10 8
102 F 9 12
103 M 7 5
104 F 5 8
;
run;
PROC SUMMARY data=have;
CLASS Gender;
var Score: ;
output out=summary_want;
run;
PROC PRINT data=summary_want;
where _STAT_='MEAN';
run;
/* end of program */
Have a nice Sunday evening!
Koen
Hello again,
(See also previous reply!)
Or do you want this? (It's not very clear from your question).
data have;
input ID $ Gender $ Score1 Score2;
cards;
101 M 10 8
102 F 9 12
103 M 7 5
104 F 5 8
;
run;
PROC SUMMARY data=have;
CLASS Gender;
var Score: ;
output out=summary_want(where=(_STAT_='MEAN') drop=_TYPE_ _FREQ_);
run;
data summary_want;
set summary_want;
MeanScore1Score2 = mean(Score1,Score2);
run;
/* end of program */
Koen
Hello,
On top of the previous 2 replies I have given,
see here:
SAS Tip: Many Means to a Mean
Posted 02-12-2018 02:07 PM
https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Many-Means-to-a-Mean/m-p/436417#M...
Koen
What is it you want in that first output column you have labeled ALL?
I cannot figure out what statistic you want in that first column. Here is want the raw output of PROC MEANS/SUMMARY can easily produce.
proc summary data=have ;
class gender;
var score1 score2;
output out=want mean= ;
run;
Results:
Obs Gender _TYPE_ _FREQ_ Score1 Score2 1 0 4 7.75 8.25 2 F 1 2 7.00 10.00 3 M 1 2 8.50 6.50
Thank you. You all are so nice!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.