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

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 518 views
  • 1 like
  • 3 in conversation