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
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: