data a;
infile datalines;
input x y $ z;
datalines;
1 a 27
1 a 33
1 b 45
2 a 52
2 b 69
3 b 70
4 a 82
4 c 91
;
run;
data b;
set a;
by x y;
if first.y;
run;
proc print data=b;
run;
data a;
infile datalines;
input x y $ z;
datalines;
1 a 27
1 a 33
1 b 45
2 a 52
2 b 69
3 b 70
4 a 82
4 c 91
;
run;
data b;
set a;
by x y;
if first.y;
run;
proc print data=b;
run;
b 70这个观测怎么也会有呢?
俺是SAS新手,说错了免罚。
data are sorted by x y, when use first.y to output observations, all obs with y firstly appearing within sorted x group will be written to data b:
1 a 27
1 a 33
1 b 45
2 a 52
2 b 69
3 b 70 (it is first time for b to appear when x=3, this is why obs 3 b 70 is reported.)
4 a 82
4 c 91