The simpler the better
data have;
input StudentId score @@;
datalines;
1 5 1 4 1 4 1 3 1 3 1 2 1 5 2 1
2 1 2 1 2 2 2 3 2 1 3 4 3 4
;
data want;
do until(last.studentId);
set have; by studentId;
where score is not missing;
v2 = v1;
v1 = v0;
v0 = score;
end;
if not missing(v2) then do;
Highest = max(of v:);
Average = mean(of v:);
end;
keep studentId average highest;
format average 4.1;
run;
proc print data=want noobs; run;
thanks @MikeZdeb
... View more