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

Hi guys,

 

I know it should be a super easy question but I cannot get the results.

 

ID              Var

1001

1002

1003

1004

1005

1006

1007

.....

 

I would like to select observations whose IDs are 1001, 1004,1012 and 1043. These IDs are not selected following a pattern but randomly. I tried the code below but it did not work.

data want;
set have;
if ID = '1001';
if ID = '1004';
if ID = '1012';
if ID = '1043';
run;

what code do I need to use? thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

HI @dapenDaniel   Please take a look at SAS Operators specifically IN operator

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

HI @dapenDaniel   Please take a look at SAS Operators specifically IN operator

dapenDaniel
Obsidian | Level 7

Hi @novinosrin Thank you!

BrahmanandaRao
Lapis Lazuli | Level 10
data test;
input id  name$	;
datalines;
1001	 judy		
1002  louise
1003  mary  
1004  philip
1012  robert
1006  ronald
1043  thomas
1008  william
;
run;


data test1;
set test;
where id in ( 1001  1004  1012  1043);
run;

This output like you want rejoinder me 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 731 views
  • 2 likes
  • 3 in conversation