Hi all,
I have a data set like this (see below). There are duplicate observations within some survey waves. Now I want to remove the duplicate observations with the highest "visit age" from the sample. What should I do?
The original data set:
| ID | WAVE | Visit age |
| 1231 | 1 | 45 |
| 1231 | 2 | 46 |
| 1231 | 2 | 47 |
| 1232 | 1 | 55 |
| 1233 | 1 | 56 |
| 1234 | 1 | 34 |
| 1234 | 1 | 35 |
| 1234 | 2 | 38 |
The dataset that I want:
| ID | WAVE | Visit age |
| 1231 | 1 | 45 |
| 1231 | 2 | 46 |
| 1232 | 1 | 55 |
| 1233 | 1 | 56 |
| 1234 | 1 | 34 |
| 1234 | 2 | 38 |
Thank you very much!
@zjppdozen wrote:
Hi all,
I have a data set like this (see below). There are duplicate observations within some survey waves. Now I want to remove the duplicate observations with the highest "visit age" from the sample. What should I do?
The original data set:
ID WAVE Visit age 1231 1 45 1231 2 46 1231 2 47 1232 1 55 1233 1 56 1234 1 34 1234 1 35 1234 2 38
The dataset that I want:
ID WAVE Visit age 1231 1 45 1231 2 46 1232 1 55 1233 1 56 1234 1 34 1234 2 38
Thank you very much!
proc summary nway missing;
class id wave;
output out=deduped(drop=_type_) min('visit age'n)=;
run;
@zjppdozen wrote:
Hi all,
I have a data set like this (see below). There are duplicate observations within some survey waves. Now I want to remove the duplicate observations with the highest "visit age" from the sample. What should I do?
The original data set:
ID WAVE Visit age 1231 1 45 1231 2 46 1231 2 47 1232 1 55 1233 1 56 1234 1 34 1234 1 35 1234 2 38
The dataset that I want:
ID WAVE Visit age 1231 1 45 1231 2 46 1232 1 55 1233 1 56 1234 1 34 1234 2 38
Thank you very much!
proc summary nway missing;
class id wave;
output out=deduped(drop=_type_) min('visit age'n)=;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.