a********a 发帖数: 346 | 1 I have a dataset - one like the following, I already sorted by id visit value,
one:
id visit value
1 0 8.4
1 0 3
1 0 2
2 0 5
2 0 2
2 1 3
2 2 4
2 2 2
2 3 5
I want to get a data set -two like the following,i.e. I only selected the
obersavation for the visit with the largest value. The other duplicate
visits are deleted.
two
id visit value
1 0 8.4
2 0 5
2 1 3
2 2 4
2 3 5
I did not figure out | p********a 发帖数: 5352 | 2 这个用PROC SQL就行了
select id, visit,max(value) as value from xxx
group by id,visit
或者用DATA STEP的FIRST.VAR,复杂些 | l***a 发帖数: 12410 | 3 data b;
set a;
by id visit;
if first.visit;
run;
value,
【在 a********a 的大作中提到】 : I have a dataset - one like the following, I already sorted by id visit value, : one: : id visit value : 1 0 8.4 : 1 0 3 : 1 0 2 : 2 0 5 : 2 0 2 : 2 1 3 : 2 2 4
| a********a 发帖数: 346 | 4 You guys are the best. Thanks. |
|