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