*Copyright @ www.mycsg.in;
Create input dataset
data scores; infile cards truncover; input usubjid$ item score; cards; 1001 1 93 1001 2 80 1001 3 80 1002 1 90 1002 2 95 1002 3 97 1003 1 100 1003 3 98 ; run;
Find the total number of records for each student
proc sort data=scores; by usubjid; run; data output; set scores; by usubjid; retain ntests; if first.usubjid then ntests=1; else ntests=ntests+1; run;
View Data
Find the overall score for each usubjid value
proc sort data=scores; by usubjid; run; data output; set scores; by usubjid; retain total; if first.usubjid then total=score; else total=total+score; run;
View Data
Find the highest score for each usubjid value
proc sort data=scores; by usubjid; run; data output; set scores; by usubjid; retain max; if first.usubjid then max=score; else if score gt max then max=score; run;
View Data
Find the lowest score for each usubjid value
proc sort data=scores; by usubjid; run; data output; set scores; by usubjid; retain min; if first.usubjid then min=score; else if score lt min then min=score; run;
View Data