%*-- 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
*/
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.