https://communities.sas.com/t5/ODS-and-Base-Reporting/Remove-quotes-from-macro-variable-LET/m-p/2288...
Using the code from the above link, I was trying to remove the quotes from the values of the macro variable &varlist below.
%let varlist ="CVDLAYCA31" "CVDLAYCA42" "CVDLAYCA53" "CVDLAYDN31" "CVDLAYDN42" "CVDLAYDN53" "CVDLAYPM31" "CVDLAYPM42" "CVDLAYPM53" "CVVACCINE42" "CVVACCINE53" "BOOSTERSHOT53"; %put %qsysfunc(dequote(&varlist));
Got output in the SAS Log: CVDLAYCA31
Desired output: CVDLAYCA31 CVDLAYCA42 CVDLAYCA53 CVDLAYDN31 CVDLAYDN42 CVDLAYDN53 CVDLAYPM31 CVDLAYPM42 CVDLAYPM53 CVVACCINE42 CVVACCINE53 BOOSTERSHOT53
Issue: I get only one value with the quotes from the list, not the remining values.
What changes would I make to the code %put %qsysfunc(dequote(&varlist)); to get the desired output?
Thanks.
That is not what the DEQUOTE() function does. To use that function you would have to first pull out each quoted sub-string.
If you juts want to remove a character (or a list of characters) use the COMPRESS() function.
%put %qsysfunc(compress(&varlist,%str(%")));
If the list might have some of them quoted with single quotes then remove both in one call.
%put %qsysfunc(compress(&varlist,'"')));
That is not what the DEQUOTE() function does. To use that function you would have to first pull out each quoted sub-string.
If you juts want to remove a character (or a list of characters) use the COMPRESS() function.
%put %qsysfunc(compress(&varlist,%str(%")));
If the list might have some of them quoted with single quotes then remove both in one call.
%put %qsysfunc(compress(&varlist,'"')));
I deleted the last parenthesis from your code as follows.
%put %qsysfunc(compress(&varlist,'"'));
The code has worked.
Thanks,
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.