I want to be able to automatically call a macro without having to run the individual program or using an %include statement, so I modified my sasv9.cfg file with several file locations in the SET SASAUTOS line. These file locations contain individual programs each with a single macro. I tested it, and it works.
However, I am concerned that by automatically defining the 90 KB worth of macros every SAS session, this will negatively affect the performance when using memory-intensive processes like modeling. Therefore, 1) does anyone know where these user-defined macros are stored during a SAS session? Is it the hard drive, the protected system memory allocated by the memsize option, or somewhere else? 2) Does anyone know how to determine the amount of memory that the user-defined sas macros take up?
Thanks,
Jennifer
@jchang53 wrote:
I want to be able to automatically call a macro without having to run the individual program or using an %include statement, so I modified my sasv9.cfg file with several file locations in the SET SASAUTOS line. These file locations contain individual programs each with a single macro. I tested it, and it works.
However, I am concerned that by automatically defining the 90 KB worth of macros every SAS session, this will negatively affect the performance when using memory-intensive processes like modeling.
These macros are not stored in memory. SAS does not look for macros while you are modeling. SAS only looks for macros and does the search when it encounters a macro in your program that it doesn't already recognize, and then it compiles the macro and stores the compiled macro on the hard disk in the WORK library, and from there the compiled macro is loaded into memory.
Therefore, 1) does anyone know where these user-defined macros are stored during a SAS session? Is it the hard drive, the protected system memory allocated by the memsize option, or somewhere else?
SAS stores the compiled macro in WORK.SASMACR, which is stored somewhere on the hard drive in the WORK directory.
2) Does anyone know how to determine the amount of memory that the user-defined sas macros take up?
Macros do not take up memory, except when the compiled macros are actually called by your program. If you have 89K of macros on your disk, and your program uses 1K of macros when the program runs, then the compiled amount of those 1K macros is stored in memory. But I do not know how to determine how much memory this takes up.
It sounds like (reading between the lines) that you are experiencing speed issues when performing modeling. If that's the case, describe the problem; however the amount of macros on disk that SAS can access is not the problem.
@jchang53 wrote:
I want to be able to automatically call a macro without having to run the individual program or using an %include statement, so I modified my sasv9.cfg file with several file locations in the SET SASAUTOS line. These file locations contain individual programs each with a single macro. I tested it, and it works.
However, I am concerned that by automatically defining the 90 KB worth of macros every SAS session, this will negatively affect the performance when using memory-intensive processes like modeling.
These macros are not stored in memory. SAS does not look for macros while you are modeling. SAS only looks for macros and does the search when it encounters a macro in your program that it doesn't already recognize, and then it compiles the macro and stores the compiled macro on the hard disk in the WORK library, and from there the compiled macro is loaded into memory.
Therefore, 1) does anyone know where these user-defined macros are stored during a SAS session? Is it the hard drive, the protected system memory allocated by the memsize option, or somewhere else?
SAS stores the compiled macro in WORK.SASMACR, which is stored somewhere on the hard drive in the WORK directory.
2) Does anyone know how to determine the amount of memory that the user-defined sas macros take up?
Macros do not take up memory, except when the compiled macros are actually called by your program. If you have 89K of macros on your disk, and your program uses 1K of macros when the program runs, then the compiled amount of those 1K macros is stored in memory. But I do not know how to determine how much memory this takes up.
It sounds like (reading between the lines) that you are experiencing speed issues when performing modeling. If that's the case, describe the problem; however the amount of macros on disk that SAS can access is not the problem.
The compiled version of the macro will reside by default in the Work library in a catalog called SASmac in some form, there might be a digit after the text.
The autocall macros shouldn't have any affect as they aren't loaded unless used. The only effect you should see is when they actually execute. There is a possibility that the OS may cache the code in memory but if the memory is needed when not executing the macro it should be overwritten by the active process.
For performance issues worry a lot more about disk IO operations.
%put %sysfunc(pathname(SASAUTOS));
As others have already written, macros in the SASAUTOS autocall libraries do not take up memory when not used, they just reside in the .sas files.
If SAS encounters what appears to be a macro call, it scans the autocall libraries in the order given in the SASAUTOS options, until it finds a macro that matches the name. It then compiles that macro to WORK.SASMACR, and will not reread the program, it just grabs the compiled macro from your WORK library if you call the macro again. When not used, the compiled macro resides on disk, in WORK.SASMACR.
So the only way having many paths in your SASAUTOS will slow down performance is if SAS has to scan a very large number of folders to find the right macro. Normally that is not a problem.
@s_lassen wrote:
So the only way having many paths in your SASAUTOS will slow down performance is if SAS has to scan a very large number of folders to find the right macro. Normally that is not a problem.
Yes, correct; and this slowdown would not affect SAS performance during modeling.
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.