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

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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