BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
VinnyR
Calcite | Level 5

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 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Use single quotes instead of double quotes. The macro processor does not resolve macro triggers inside of single quotes.

data ....;
  ...
  myvar =  'ABZ%ABZ';
  ....
run;

View solution in original post

14 REPLIES 14
novinosrin
Tourmaline | Level 20
%let var=%nrstr(ABZ%ABZ);

%put &=var;

%put &=var;
VAR=ABZ%ABZ

VinnyR
Calcite | Level 5
Thanks Novinosrin
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

VinnyR
Calcite | Level 5

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?

 

 

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

andreas_lds
Jade | Level 19

@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.

VinnyR
Calcite | Level 5
Sorry, that was a mistake, rectified!
VinnyR
Calcite | Level 5
I did use data step
VinnyR
Calcite | Level 5
That was a mistake, I have edited the initial post
Tom
Super User Tom
Super User

Use single quotes instead of double quotes. The macro processor does not resolve macro triggers inside of single quotes.

data ....;
  ...
  myvar =  'ABZ%ABZ';
  ....
run;
andreas_lds
Jade | Level 19
Just use single instead of double/normal quotes.
VinnyR
Calcite | Level 5

Thanks all for your contributions.

 

Regards,

Vinny

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 14 replies
  • 1510 views
  • 0 likes
  • 6 in conversation