| Have: | |||
| ID | v1 | v2 | v3 |
| 1 | -3 | a | a |
| 1 | -2 | b | b |
| 1 | -1 | c | b |
| 1 | 1 | d | b |
| 2 | -20 | a | a |
| 2 | -6 | b | b |
| 2 | -3 | c | b |
| 2 | -2 | d | b |
| 3 | 1 | a | a |
| want: | |||
| ID | v1 | v2 | v3 |
| 1 | 1 | d | b |
| 2 | -2 | d | b |
| 3 | 1 | a | a |
I am trying to find one unique observation per id. v1 ranges from 1 to -20. I am trying to output the highest and unique value possible for v1.
Very easy.
proc sort data=have;
by id v1;
run;
data want;
set have;
by id;
if last.id;
run;
Is the ID and v1 combination unique?
If so, use SQL with group by ID having max(v1) = v1.
CFC_SAS_Communities_400x225.jpg
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.