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

Hi all, I am fairly new with SAS and I have two datasets.

 

One data-set is like a population data, the other is just a list of IDs. 

 

What I want is to match the data-sets or filter out the population data set in a quick way, so that population data set will only keep rows with the same ID as the ones in the other list. There are 85 unique IDs that don't follow any specific format (just 10 random characters) I wish to keep and I tried using:

 

Data want

set have

if find (ID, 'first ID', 'second ID', 'third ID', etc [up to the 85 unique IDs]...);

run;

 

But keep getting error The FIND function call has too many arguments.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

You might do better with:

 

proc sql;
create table want as
select * 
from have
where id in (select id from ID_list);
quit;
PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

Try

 

Data want;
set have;
if ID in ( 'first ID', 'second ID', 'third ID', etc [up to the 85 unique IDs]...);
run;
PG
Bounce
Fluorite | Level 6
Thank you for this!
PGStats
Opal | Level 21

You might do better with:

 

proc sql;
create table want as
select * 
from have
where id in (select id from ID_list);
quit;
PG
Bounce
Fluorite | Level 6
Thank you!

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