BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
pkm_edu
Quartz | Level 8
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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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,'"')));

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

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,'"')));
pkm_edu
Quartz | Level 8

I deleted the last parenthesis from your code as follows.

%put %qsysfunc(compress(&varlist,'"'));

The code has worked.

Thanks,

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 771 views
  • 0 likes
  • 2 in conversation