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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 1659 views
  • 0 likes
  • 2 in conversation