%*-- 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
*/
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: