If I have a data set with a column like this:
ID
A1028
A30900
B7018
I am trying to convert this to a list with the values in single quotes, separated by commas like this:
&ID= 'A1028','A30900','B7018'
I can make a comma separated list by:
proc sql;
select distinct ID
into :ID separated by ","
from data;
quit;
to get
&ID= A1028,A30900,B7018
But I can’t find how to add single quotes. I have tried several solutions, but they have double quotations. Ultimately I am trying to use this macro variable to filter a larger data set:
proc sql;
select *
from data2
where ID in (&ID.)
quit;
But I think it will only work with single quotes because ID is a character value. It did not work with unquoted IDs or double quoted IDs. Any help is greatly appreciated.