BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abhinayingole
Obsidian | Level 7
%macro p;
  %let _1p = 184;
%mend p;

%p;

%put RESULT = &_1p.;

I am getting warning for above code as...

WARNING: Apparent symbolic reference _1P not resolved.

 

can anyone please help

1 ACCEPTED SOLUTION

Accepted Solutions
AMSAS
SAS Super FREQ

Yes, because your _1p macro variable is local to the p macro

Scope of macro variables

 

%macro p;
  %global _1p ;
  %let _1p = 184;
%mend p;

%p;

%put RESULT = &_1p.;

View solution in original post

3 REPLIES 3
AMSAS
SAS Super FREQ

Yes, because your _1p macro variable is local to the p macro

Scope of macro variables

 

%macro p;
  %global _1p ;
  %let _1p = 184;
%mend p;

%p;

%put RESULT = &_1p.;
abhinayingole
Obsidian | Level 7
I need to use _1p after the macro p ends.
any suggestion
Tom
Super User Tom
Super User

If you want _1P to be available after the P macro finishes running the make sure it is NOT local to P.

%let _1p=BEFORE;
%p;
%put &=_1p;

You could modify the macro to force it to be GLOBAL if is doesn't already exist.

%macro p;
%if not %symexist(_1p) %then %global _1p;
%let _1p=from macro p;
%mend p;

Terminology correction: You macro call worked fine. It was the macro variable you tried to reference after the macro had finished running that was generating the warning.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 986 views
  • 2 likes
  • 3 in conversation