Hi,
I am trying to create a variable which will have value like "ABZ%ABZ". How can I create a variable which will contain this variable without the warning that Apparent invocation of macro ABZ nor resolved. Can somebody Guide?
Thanks,
Vinny
Use single quotes instead of double quotes. The macro processor does not resolve macro triggers inside of single quotes.
data ....;
...
myvar = 'ABZ%ABZ';
....
run;
%let var=%nrstr(ABZ%ABZ);
%put &=var;
%put &=var;
VAR=ABZ%ABZ
The question would be why? % is a macro trigger language, so its really not a good idea to put it in there, or you will just need to keep superquoting or wrapping it to make it work. I can guarentee there are better methods to achieve whatever your outcome is.
Thanks for your replies. Please check the shell Extract that I am supposed to present the data in with the expected naming. DO you think it's unreasonable? and why?
No, there is nothing wrong with the shell, these kind of summary statistics are something quite generic. However I have never put the statistic text in a macro variable. Take a means output:
proc means...; ... output out=stats n=n mean=mean stddev=stddev...; run; data want (keep=col1 ord trt1); set stats; length col1 trt1 $50; ord=1; col1="N"; trt1=strip(put(n,best.)); output; ord=2; col1="Mean (SD)"; trt1=strip(put(mean,8.3))||" ("||strip(put(stddev,8.4))||")"; output; ... run;
Shows one simple manual datastep where values are transposed out into their correct pieces (formatted as text to get %'s and other symbols in), with the stats column being put in. You can simplify it a bit, and a lot of companies have macros to o these kind of things already.
@VinnyR wrote:
Thanks for your replies. Please check the shell Extract that I am supposed to present the data in with the expected naming. DO you think it's unreasonable? and why?
Maybe it is to late, but why do you need that in a macro-variable? Please post more information, preferable not as attachments.
To produce text output, use a data step.
In a data step, you can easily take precautions against unwanted resolution of macro triggers.
Then why do you store data in macro variables instead of a dataset or a text file?
@VinnyR wrote:
I did use data step
Use single quotes instead of double quotes. The macro processor does not resolve macro triggers inside of single quotes.
data ....;
...
myvar = 'ABZ%ABZ';
....
run;
Thanks all for your contributions.
Regards,
Vinny
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: