I ran the following program using the SAS EG. I defined a macro run_macro in the main program. I created a separate program macro_1.sas in /foldername/ folder which contains a macro macro_1. After I make changes in macro_1.sas and run the main program, why is the SAS keep running the same codes before the changes? It runs the program correctly only if I close the SAS, re-open and run. Does someone know why?
options pagesize=59 mautosource sasautos="/foldername/";
%macro run_macro;
%* ;
%macro_1;
%* ;
%mend run_macro;
%run_macro;
You may also need to set the option MREPLACE to enable a previously defined macro to be replaced with the newer version.
You are observing standard behavior. SAS does not look for the macro definition each time you use the macro. It only searches for the macro definition if the macro is not yet defined. So you have changed the definition, but SAS doesn't look for the new definition.
For a contining EG session, try adding a %INCLUDE statement to bring in the file holding the revised macro definition. %INCLUDE can be placed either inside or outside a macro definition, wherever you see fit to redefine a macro.
You may also need to set the option MREPLACE to enable a previously defined macro to be replaced with the newer version.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.