BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nrjn7
Fluorite | Level 6
IDEventCodevalue
1A  
1B16
1B17
1B18
2A57
2B68

 

want

IDEventCodeValue
1A  
1B16
2A57
2B68

 

This is just an example, but for my dataset, I need to be able to compare ID and code.

If the ID and code are the same, then I want to only retain one row and delete all the other rows.

 

Can you please suggest?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Easiest might be

 

Proc sort data=have out=want nodupkey;

   by Id code;

run;

 

Create a new output data set Want so you don't accidentally delete things you want. This way your original data set remains.

 

If EVENT plays any role in this process, which you did not mention, then you may want to sort by ID Event Code; Maybe.

View solution in original post

1 REPLY 1
ballardw
Super User

Easiest might be

 

Proc sort data=have out=want nodupkey;

   by Id code;

run;

 

Create a new output data set Want so you don't accidentally delete things you want. This way your original data set remains.

 

If EVENT plays any role in this process, which you did not mention, then you may want to sort by ID Event Code; Maybe.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 465 views
  • 0 likes
  • 2 in conversation