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.

 

 

 

 

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