How can I accomplish the following:
%put &q_start_date --> resolves to 01MAR2022
what I need the variable to resolve to is '01MAR2022'
Can anyone help me with the issue.
Thanks in advance!
Better to apply the quotes when the macro variable is used, rather than include the quotes in the macro variable value. So when the macro variable is used, for example in a DATA step, you can do something like this
if date > "&q_start_date"d then ... ;
If that's not what you are looking for, please be more specific about how this macro variable will be used.
If you can use double quotes (as you should be able to in normal SAS code) then just use:
%put "&q_start_date";
If you need the single quotes use %bquote().
%put %bquote('&q_start_date');
If the macro quoting added by %BQUOTE() causes trouble remove it.
%put %unquote(%bquote('&q_start_date'));
How do you intend to use the macro variable? If you need it for comparisons or calculations, store the raw date value. See Maxim 28.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.