BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

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 

4 REPLIES 4
Quentin
Super User

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.  

yabwon
Amethyst | Level 16

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Tom
Super User Tom
Super User

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';
Patrick
Opal | Level 21

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 256 views
  • 5 likes
  • 5 in conversation