I am big fan of PRXCHANGE for this kind of problem which is origined from @Patrick
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
68
69 %let list_have = word1 word2 word3;
70 %let list="%sysfunc(prxchange(s/\s+/" "/,-1,&list_have))";
71 %put &list ;
"word1" "word2" "word3"
72
73
74 %let list_have = word1 word2 word3;
75 %let list=%bquote('%sysfunc(prxchange(s/\s+/' '/,-1,&list_have))');
76 %put &list ;
'word1' 'word2' 'word3'
77
78
79 %let list_have = word1 word2 word3;
80 %let list=%sysfunc(prxchange(s/\s+/|/,-1,&list_have));
81 %put &list ;
word1|word2|word3
82
83 %let list_have = word1 word2 word3;
84 %let list=%sysfunc(prxchange(s/(\w+)/_$1%str(,)/,-1,&list_have));
85 %put &list ;
_word1, _word2, _word3,
86
87
88 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
99
... View more