Hi Experts,
Given the program below how do I prevent the warnings?
data test;
call symputx('test','&test2');
test=resolve('&test');
run;
Thanks
Hi,
Is your goal to make a macro variable TEST which has the value &test2, and then use the RESOLVE function to write that value to a data step variable TEST without treating the & in the value as a macro trigger?
If so, then %superq can help:
1 data test; 2 call symputx('test','&test2'); 3 test=resolve('%superq(test)'); 4 put test= ; 5 run; test=&test2 NOTE: The data set WORK.TEST has 1 observations and 1 variables.
but unless this is an academic exercise, it might be worth describing more of the big picture behind your goal.
Which warning?
Macro variables do not resolve inside single quotes. If you have a macro variable named test2 and want the value treated as text you would use "&test2"
You may have to share exactly what you expect as it isn't obvious from either your question or code.
Macro variable &test2 would need to exist when using resolve(). If you just want to retrieve the value from &test then use symget() instead.
%let test2=some value;
data test;
call symputx('test','&test2');
test=resolve('&test');
test2=symget("test");
run;
Hi,
Is your goal to make a macro variable TEST which has the value &test2, and then use the RESOLVE function to write that value to a data step variable TEST without treating the & in the value as a macro trigger?
If so, then %superq can help:
1 data test; 2 call symputx('test','&test2'); 3 test=resolve('%superq(test)'); 4 put test= ; 5 run; test=&test2 NOTE: The data set WORK.TEST has 1 observations and 1 variables.
but unless this is an academic exercise, it might be worth describing more of the big picture behind your goal.
Without %superq, the resolve function resolves the macro variable reference &test, to the value &test2 and it sees that as a macro variable reference so tries to resolve the macro variable TEST2, which doesn't exist, so it throws the warning.
With %superq the resolve function resolves the macro variable reference &test, to the value [masked &]test2 which is not a macro variable reference so there is no attempt to resolve TEST2. The job of %SUPERQ is to resolve a macro variable, and then mask any & or % in the resolved value.
To be honest, I wasn't sure %SUPERQ would work here, because I don't use the RESOLVE function much. But it looks to me like it is doing its usual job.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.