Dear,
I came across a situation where I used macro variables in my pgm created by using macro function %str. I got error. when I removed %str function I did not get error. Please help me understand. Thank you
I created 4 macro variables. Two using %str function. Other two not. When I run %one macro using macro variables created using %str function. I am getting error. But when i run with other two, I am not. Please help.
%let gm_ba = %str(03) ;
%let gm_snum = %str(a0310) ;
%let gm_ca = 03 ;
%let gm_tnum = a0310 ;
data aaa;
input a $ b;
datalines;
a 1
b 2
c 3
;
%macro one;
data c&gm_ba&gm_snum.01;
set aaa;
run;
%mend;
%one;
%macro one;
data c&gm_ca&gm_tnum.01;
set aaa;
run;
%mend;
%one;
Always look at the log.
You'll see that quoting the macro variable using %str() adds non-printable characters.
Use the %unquote() function in your data step.
Reading this article: https://stats.idre.ucla.edu/wp-content/uploads/2016/02/bt185.pdf will help you understand secrets of macro quoting.
All the best
Bart
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.