jingju11 发表于 2012-12-18 08:28
I wrote a function-like macro %getMedian for that just for fun. You can read here_is_link.
jingju
Actually, I found another way to solve this problem from the sashelp doc...
data grade;
input Name $ 1-8 Gender $ 11 Status $13 Year $ 15-16
Section $ 18 Score 20-21 FinalGrade 23-24;
datalines;
Abbott F 2 97 A 90 87
Branford M 1 98 A 92 97
Crandell M 2 98 B 81 71
Dennison M 1 97 A 85 72
Edgar F 1 98 B 89 80
Faust M 1 97 B 78 73
Greeley F 2 97 A 82 91
Hart F 1 98 B 84 80
Isley M 2 97 A 88 86
Jasper M 1 97 B 91 93
;
proc means data=Grade noprint descend;
class Status Year;
var Score FinalGrade;
output out=Sumdata (where=(status='1' or _type_=0))
mean= median(finalgrade)=MedianGrade;
run;
proc print data=Sumdata;
title 'Exam and Course Grades for Undergraduates Only';
title2 'and for All Students';
run;