BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zjppdozen
Fluorite | Level 6

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:

IDWAVEVisit age
1231145
1231246
1231247
1232155
1233156
1234134
1234135
1234238

 

The dataset that I want:

IDWAVEVisit age
1231145
1231246
1232155
1233156
1234134
1234238

 

Thank you very much!

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

@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;

View solution in original post

2 REPLIES 2
data_null__
Jade | Level 19

@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
Fluorite | Level 6
This code works! Thank you very much!
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1107 views
  • 0 likes
  • 2 in conversation