BookmarkSubscribeRSS Feed
Sajid01
Meteorite | Level 14

The problem appears to be of scope of the macro variable VARIABLE_MACRO_VAR_RESOLVES.
As you are defining this variable in the macro_var,  declare it global.

%global  VARIABLE_MACRO_VAR_RESOLVES;

Without this macro resolution fails.
With this in view I have run a test code mimicking your code and see everything work.

My code is given below

/*
Step 1 : Create the macro macro_var and store in the auocall location
with the name macro_var.sas
The location of my auto call library is /home/myuid/Master
*/
 %macro macro_var;
%global  VARIABLE_MACRO_VAR_RESOLVES;
%let VARIABLE_MACRO_VAR_RESOLVES="resolved";
%put "This from inside the macro macro_var";
%put &=VARIABLE_MACRO_VAR_RESOLVES ;
%mend macro_var;

The above is saved as macro_var.sas at my auto call library  location /home/myuid/Master.
Next in created another program having macro_other as follows

Step 2 : Create the macro   macro_other and call macro_var
%let path=/home/myuid/Master;
option sasautos=("&path" sasautos) mautosource mrecall;
%macro macro_other;
%macro_var
%put " From inside the  macro_other but outside macro_var";
%put &=VARIABLE_MACRO_VAR_RESOLVES. ;
%mend macro_other;

%macro_other
%put "From Outside the _macro_other";
%put &=VARIABLE_MACRO_VAR_RESOLVES. ;

I executes the second code and the log is as follows

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         %let path=/home/myuid/Master;
 70         option sasautos=("&path" sasautos) mautosource mrecall;
 71         %macro macro_other;
 72         %macro_var
 73         %put " From inside the macro_other but outside macro_var";
 74         %put &=VARIABLE_MACRO_VAR_RESOLVES. ;
 75         
 76         %mend macro_other;
 77         
 78         %macro_other
 "This from inside the macro macro_var"
 VARIABLE_MACRO_VAR_RESOLVES="resolved"
 " From inside the macro_other but outside macro_var"
 VARIABLE_MACRO_VAR_RESOLVES="resolved"
 79         %put "From Outside the _macro_other";
 "From Outside the _macro_other"
 80         %put &=VARIABLE_MACRO_VAR_RESOLVES. ;
 VARIABLE_MACRO_VAR_RESOLVES="resolved"


I have tested on SAS® OnDemand for Academics.

 

 

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 15 replies
  • 3091 views
  • 2 likes
  • 4 in conversation