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: 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!

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