BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jchang53
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@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.

 

--
Paige Miller

View solution in original post

5 REPLIES 5
PaigeMiller
Diamond | Level 26

@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.

 

--
Paige Miller
ballardw
Super User

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.

Ksharp
Super User
%put %sysfunc(pathname(SASAUTOS));
s_lassen
Meteorite | Level 14

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.

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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