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