OPTIONS MAUTOSOURCE SASAUTOS=("/.../HYFIprep/sasmacro","/.../HYFIp/sasmacro","/.../prod/sasmacro");
%CHECK_ENV; /* pour trouver le numéro de l'environnement sur lequel la job batch est soumise */
%LET SUFENV = &envN; /* p pour prod - 1,2,3.... pour la dev */
%LET SASENV = &envP; /* Pour les sasyyyy*/
%put &=SUFENV;
%put &=SASENV;
Hello the same macro function name %check_env could be found in various subfolder and the version of the macro function could differ a little bit. How to check the version that is trigger?
If I trigger the macro function %check_env from the subfolder /.../HYFIprep does the version of %check_env will be the one from /.../HYFIprep/sasmacro
If you set the system option mautocomploc, SAS will write a note to the log when it compiles an autocall macro that shows the file that was compiled, e.g.:
2 options mautocomploc ;
93 %put %lowcase(foo) ;
MAUTOCOMPLOC: The autocall macro LOWCASE is compiling using the autocall source file C:\Program
Files\SASHome\SASFoundation\9.4\core\sasmacro\lowcase.sas.
foo
If you turn on the option mautolocdisplay, it will write similar information to the log every time an autocall macro is invoked.
To your second question, calling a macro from a subfolder does not effect which macro will be compiled. When you call %check_env for the first time, SAS will look through the autocall libraries in the order they are listed in SASAUTOS, until it finds a file check_env.sas.
Other option I'd recommend would be creating a SAS package out of those macros.
Here are two articles explaining why is it a good idea:
1) https://pages.mini.pw.edu.pl/~jablonskib/SASpublic/Paper_012-SESUG2025.pdf
2) https://pages.mini.pw.edu.pl/~jablonskib/SASpublic/Paper_116-PharmaSUG2025.pdf
Here is a video presentation (22 minutes): https://youtu.be/4QRr7sUhO9E
And here is a tutorial (from 0 to hero): https://github.com/yabwon/HoW-SASPackages
Bart
As long as you have not modified the SASAUTOS setting since the time that it was used to find the macro and compile it you could use this macro.
https://github.com/sasutils/macros/blob/master/maclist.sas
For every compiled macro it will hunt through the paths listed in the SASAUTOS option and find the first file with a name that matches the name of the compiled macro.
The result is a SAS dataset.
attrib MACRO length=$32 label='Macro name';
attrib FOUND length=3 label='Found? (0/1)';
attrib FILE length=$36 label='Filename';
attrib DNAME length=$200 label='Directory name';
Another option that I'm using frequently for autocall macros: options mautolocdisplay;
With this option a log message get printed that tells you where the macro has been compiled from whenever you use the macro.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.