Amadeus cookies policy - you'll see this message only once.

Amadeus use cookies on this website. They help us to know a little bit about you and how you use our website, which improves the browsing experience and marketing - both for you and for others. They are stored locally on your computer or mobile device. To accept cookies, continue browsing as normal. Or, go to the privacy policy for more information.

Stored Macros Where's the Source?

Until V9, there was a potential shortcoming when using compiled stored macros; only the compiled form was stored by SAS, so that you had to make sure you didn't lose the source code - in case it was needed for recompilation when a new version of SAS came along, or in case you forgot what your macro actually did. Under V9, you can - and should! - specify that the source code is saved with the compiled macro.

To set the whole thing up, you need to specify a couple of system options. MSTORED enables compiled stored macros, and SASMSTORE specifies the library in which the macro catalogue is to be stored. The name of the catalogue itself is always SASMACR.

libname sasdir "c:SAS"; 
options mstored sasmstore=sasdir; 

Now you can define your macro. STORE causes the compiled macro is to be stored; SOURCE causes the source code to be stored with the macro; DES= causes a description to be added to the macro properties. Here is a simple macro defined in this way:

%macro example(stuff) /store source des='Demonstration'; 
     %put The parameter was &stuff; 
%mend example;

Now the macro can be called:


producing the output:

The parameter was insignificant 

If you want to remind yourself how this result was achieved, you can easily retrieve the source of the macro using %COPY.

%copy example/source; 

produces the output:

%macro example(stuff) /store source des='Demonstration'; 
    %put The parameter was &stuff; 
%mend example;