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

Hi All,

 

I have data like this.

 

data:

obsidabcde
11010 0
210100.51
3111.2050.50
4115.901500.50
5113.302000.50
61512600.50
71513000.50
81513600.50

 

want:

obsidabcde
11010 0
210100.51
3111.2050.50
4115.901500.50
5113.302000.50
61512600.50

 

I want  keep only one observation where a=5 and b=1

 

please let me know how to do this  in sas.

 

Thanks in advance.

2   

1 ACCEPTED SOLUTION

Accepted Solutions
ari
Quartz | Level 8 ari
Quartz | Level 8

Answer: the follwing code gives what i want.

 

Proc sort data= data out= want;

by id a b e;

run;

 

 

Thanks forum.

View solution in original post

4 REPLIES 4
ballardw
Super User

Probably the easiest if the file is not extremely large is

 

Proc sort data=have out=want noduprecs;

   by id;

run;

ari
Quartz | Level 8 ari
Quartz | Level 8
I have updated the dataset, what if several variables like var3 exist in the dataset?
ballardw
Super User

You may need to post a more complete example if your data is more complex.

 

 

1 2 3 4 5

1 2 3 6 6   <only var3 duplicates does this get deleted?>

1 2 3 4 6   <only var3 and var4 duplicate the first, does this get deleted?>

1 2 3 4 5  <all of var3, var 4 and var5 duplicate the first, the original proc sort solution would work>

ari
Quartz | Level 8 ari
Quartz | Level 8

Answer: the follwing code gives what i want.

 

Proc sort data= data out= want;

by id a b e;

run;

 

 

Thanks forum.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1559 views
  • 0 likes
  • 2 in conversation