由买买提看人间百态

topics

全部话题 - 话题: prevyear
(共0页)
A****1
发帖数: 33
1
来自主题: Statistics版 - 请教一道SAS题
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;
(共0页)