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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.