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 !!
Simply loose the double quotes. Like this
%let names = 'Alfred', 'Alice';
data want;
set sashelp.class;
where name in (&names.);
run;
Simply loose the double quotes. Like this
%let names = 'Alfred', 'Alice';
data want;
set sashelp.class;
where name in (&names.);
run;
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).
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!
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.