BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
singhsahab
Lapis Lazuli | Level 10

Hi All,

 

I've a macro variable containing the subject value like %let subject='10660','106661','106663','10664','10665','16666','10667','10668','106669','10670','10671','10672','10667','106674','106675','106676','106677','10679','106681','10682','106684','10685','10686','10687','16688','106689','106690','106692','305771','99999'; and it contains approx 3000 subject. 

i'm trying to get only 3000 subject data based on below code . but i'm not able to identify why it's not working . Please share your valuable comment. 

DATA QS_2;
SET QS_1;
WHERE SUBJECT IN ("&SUBJECT");
RUN;

Thank you in advance !!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Simply loose the double quotes. Like this

 

%let names = 'Alfred', 'Alice';

data want;
   set sashelp.class;
   where name in (&names.);
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Simply loose the double quotes. Like this

 

%let names = 'Alfred', 'Alice';

data want;
   set sashelp.class;
   where name in (&names.);
run;
ballardw
Super User

When you used

WHERE SUBJECT IN ("&SUBJECT");

you created code that looks like this (short enough to see clearly)

 

where = subject in (" '10660','106661','106663' ");

So the outer double quotes make the whole value inside them as a single string, not 3000 separate strings (or three in my reduced example).

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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