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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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