A****1 发帖数: 33 | 1 data one;
input id $ age score;
cards;
A 1 100
A 2 120
A 3 150
B 2 100
B 3 140
;
run;
proc sort data=one;
by id;
run;
data two;
set one;
by id;
PrevYear=lag(score);
if first.id then PrevYear=0;
difference=ifc(PrevYear>score,'1','0');
run;
proc means data=two max mean;
by id;
var score;
output out=three(keep=id high avg) max=high mean=avg;
run;
data two;
merge two three;
by id;
run; |
|