BookmarkSubscribeRSS Feed
u63406443
Calcite | Level 5

Hi All,

 

I am try to declare a macro variable and print the macro variable in log window using the put statement, but output is not fetching. Can you help me.

Attaching the output image for reference.

 

Code:

%let pass=%str(rAk%B25%);
%put &pass;

 

Thanks.

 

Result:

 

u63406443_0-1698293433438.png

 

3 REPLIES 3
Tom
Super User Tom
Super User

Do you actually have the %B25 macro that you are trying to call?  What does it do?

 

Perhaps you meant to use %NRSTR()?  if so double the % characters to mask them.

1    %let pass=%nrstr(rAk%%B25%%);
2    %put &pass;
rAk%B25%

Your code it probably still looking for the closing ), right parenthesis, since you masked the one in the first line by prefixing it with a % character.

1    %let pass=%str(rAk%B25%);
2    %put &pass;
3    );
WARNING: Apparent invocation of macro B25 not resolved.
ERROR: Open code statement recursion detected.

Add the closing ) to your %LET.

1    %let pass=%str(rAk%B25%));
WARNING: Apparent invocation of macro B25 not resolved.
2    %put &pass;
WARNING: Apparent invocation of macro B25 not resolved.
rAk%B25)
Patrick
Opal | Level 21

The macro tokens like % complicate things a bit. %superq should help.

data _null_;
  call symput('pass','rAk%B25%');
run;
%put %%SUPERQ(pass);

 

Deciding When to Use a Macro Quoting Function and Which Function to Use

 

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 3 replies
  • 813 views
  • 1 like
  • 3 in conversation