%*-- 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
*/
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.