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).
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.