Hi,
I am trying to use the MAUTOSOURCE system option, paired with the SASAUTOS statement to compile macros, to allow them to be auto-called later. Below is my code:
%* Method 1;
options mrecall mautosource sasautos=(%sysget(sasautos) "C:\mymacros");
%* Method 2;
filename mymac "C:\mymacros";
options mrecall mautosource sasautos=(%sysget(sasautos) mymac);
Both methods above do not seem to work yet the logs are clean, when I try to resolve any macro located in the "C:/MyMacros" the warning "WARNING: Apparent invocation of macro xxx not resolved" appears. I understand this means the macro has not been autocompiled so SAS cannot see it yet.
Worth nothing, yes I can confirm the macro is named the same as the macro program itself and is located in the path above.
Any help please? I did get it working, but closed SAS and reopened to double check it worked, but it did not work. I think I am missing something obvious.
Turns out I had old code in the program calling the macro, which was resetting the settings after defining them, as displayed in my example. Removed the code and suggested code work. Rookie error.
You need to use either the INSERT= to place a new value at the beginning of a list or Append= for at the end of the list.
%* Method 1; options mrecall mautosource Append=(sasautos "C:\mymacros");
The general syntax is Append= or insert=(<list name> newvalue); List name is the option you want to work with. You do not need to recall other values, just the list name. If you ONLY want specific values then you use the <listname>=( <explicit values>)
Note: if this Append or Insert code is resubmitted you keep adding the same folder to the list. So generally try to execute the Append/insert only once as when you go to remove it you may have to remove it multiple times.
Turns out I had old code in the program calling the macro, which was resetting the settings after defining them, as displayed in my example. Removed the code and suggested code work. Rookie error.
Hi Ksharp,
I actually already use the MSTORED MACROSTORE options
libname mylib1 "C:\mymacros\Set1";
libname mylib2 "C:\mymacros\Set2";
libname mylibs (mylib1 mylib2);
libname mylib1 clear;
libname mylib2 clear;
options mstored sasmstore=mylibs;
options mrecall mautosource set = sasautos("!sasroot\core\sasmacro" "C:\mymacros");
Oddly now it does not seem to be working again after a reboot, bit confused now.
Are you storing your macro definition as source files to be found by the SASAUTOS path?
Or are you storing them in pre-compiled catalogs to be referenced from there?
Personally I never use MSTORED as I prefer to be able to look at the source code files and to be able to update individual files with operating system tools (like version control software).
Hi Tom,
The answer is both, we have "standard" macros in macro catalogues. The source code is hidden from the user, this is why we use the MSTORED / MACROSTORE options.
The macros in question here are basic SAS programs which are macros, i.e., 1 macro per SAS program with the macro name being the same as the program name. These macros should be recalled by SAS using the MRECALL, SASAUTOS and MAUTOSOURCE options, but it is not playing ball.
I have no idea if that type of hybrid system can work.
If it cannot then you might try something like this:
On startup use PROC CATALOG to copy your stored compiled macros into the session's working macro catalog. (If using Display Manager that is WORK.SASMAC and if using EG or Studio it is WORK.SASMAC1).
Then just use normal autocall for your other text based macros.
Note with this method there is no way to override your compiled macro definitions. If you want to override the definition of one of those macros you would need to run the actual definition code. Perhaps with %INCLUDE.
Hi Tom,
Yeah this method does work, and for the definitions to take over a macro say in both a catalogue and in a SAS program the entry would need to be removed from the catalogue first, or by using the %INCLUDE statement like you suggested.
After a reboot it is working now. Turns out the %sysget(sasautos) was causing an issue it returns with parenthesis which meaning the original SASAUTOS option was not correctly defined, once I resolved this I first had to reboot SAS. Then it worked.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.