%*-- single quote --*;
%macro squote(str);
%if %superq(str)= %then %return;
%local s;
%let s = %str(%');
%unquote(&s%sysfunc(tranwrd(&str,&s,&s&s))&s)
%mend squote;
%*-- comma separated quoted values --*;
%macro csqv(list, dlm=*);
%if %superq(list)= %then %return;
%local i item;
%let i = 1;
%let item = %qscan(&list, &i);
%do %while (&item ^=);
%if &i > 1 %then %*;,;
%*;%squote(&item)
%let i = %eval(&i + 1);
%let item = %qscan(&list, &i);
%end;
%mend csqv;
%*-- check --*;
proc print data=sashelp.class;
where name in (%csqv(Alfred*Alice*Barbara));
run;
/* on lst
Obs Name Sex Age Height Weight
1 Alfred M 14 69.0 112.5
2 Alice F 13 56.5 84.0
3 Barbara F 13 65.3 98.0
*/
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.