All: when performing IN operator to match words in a macro string, the quotes are required. But, the results are frustrated, would someone remind me what I have missed. This macro string is created from proc sql as below '''
proc sql noprint;
select memname into :domains separated by ' '
from sashelp.vtable
where libname='SDTM';
quit;
''' Next, I quoted the string using this statement '''
%let domains_quoted = %nrbquote(')%qsysfunc(prxchange(s/\s /%nrbquote(',')/oi,-1,&domains))%nrbquote(');
''' In log, it displayed no issues
SYMBOLGEN: Macro variable DOMAINS_QUOTED resolves to 'AE','CM','DM','DS','EG','EX',...
Then, I wish I can filter the output datasets. '''
data want;
set have;
if dname in (&domains_quoted);
run;
''' I got the error message saying:
SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing.
ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant,
a missing value, iterator, (.
Would some one remind me what I have missed in these steps? Great appreciated.
CodePudding user response:
Use the QUOTE() function to avoid the PRX step.
proc sql noprint;
select quote(memname) into :domains separated by ' '
from sashelp.vtable
where libname='SDTM';
quit;
data want;
set have;
if dname in (&domains_quoted);
run;