I have a macro variable:
%let names = name1, name2, name3, name4
The real variable can vary in length. What I want to do is make a new variable datalist, which looks like this:
‘name1’,‘name2’,‘name3’,‘name4’
I have tried to make this variable in the following way:
%str(%’)%sysfunc(tranwrd(%quote(&names.),%str(,),%str(%’ ,%’)))%str(%’))
When I run the code I get the following error:
The meaning of an identifier after a quoted string might change in a future SAS release. Inserting white space between a quoted string and the succeeding identifier is recommended.
Adding white spaces does not help though. Does anyone know a different method to construct my desired macro variable?
PS: I have seen the following question, but in that one there were no commas separating the elements in the list. SAS macro variable quotes
Use the same method used before, but take care to hide the commas in NAMES from %SYSFUNC().
%let names = name1, name2, name3, name4 ;
%let qnames = %sysfunc(tranwrd(%bquote('&names'),%str(, ),', '));