Hello - I've googled around and have seen bits and pieces of how to set up a macro autocall. Is there a tech paper that walks through an example step-by-step? I took the Macro Essentials SAS class, and autocalls were not covered there.
Thanks!
There's plenty of information out there. Did you try googling "autocall"?
Basics:
A more detailed paper:
https://support.sas.com/resources/papers/proceedings/proceedings/sugi27/p017-27.pdf
The basics of setting this up are simple. Select a folder to hold your macro definitions. Then for each macro, store it as a separate file within the folder. If you're creating a macro called %report_me save the macro definition as report_me.sas within the folder.
Yes, I had searched that and had seen those links. What I wasn't sure about was this step - how does one save in a SAS catalog? I've never worked with catalogs before and am unsure of the advantages of doing so. Sorry if this is a dumb question!!!
Store the source code for each macro in a SOURCE entry in a SAS catalog. (SOURCE is the entry type.) The name of the SOURCE entry must be the same as the macro name.
That's making it sound harder than it really is. Store the macros as text. So within report_me.sas you would expect to see:
%macro report_me (parameters)
........ definition of the macro ........
%mend report_me;
It's just a text file.
You may have been reading something about precompiled macros. That's a different topic.
I read it from here (step 3 below), which seems to be talking about something slightly different than a fileref. I'll just store in a fileref and forget about using a CATALOG argument, though it would have been interesting to try the latter.
https://v8doc.sas.com/sashtml/macro/z1328769.htm
Using SAS Catalogs as Autocall Libraries |
In Release 6.11 or later, you can use the CATALOG access method to store autocall macros as SOURCE entries in SAS catalogs. To create an autocall library using a SAS catalog, follow these steps:
libname mymacs 'SAS-data-library'; filename mymacros catalog 'mymacs.myautos';
Yes, for most programmers, that is overkill. Here's the simpler way (tailored for PCs):
http://support.sas.com/kb/24/451.html
And adding to what @Astounding wrote:
The .sas file must have the same name than the name of the macro defined in the .sas file. If the OS is UNIX/Linux then the name of the .sas file must all be lowercase (the name of the macro in the code can still be mixed case).
You then just need to store this .sas file in a folder for which a path is defined in system option SASAUTOS - or you can add the path to SASAUTOS. SASAUTOS holds the names of all the paths (and libraries) under which SAS will be looking for the macro when you call it.
Can anyone explain any advantages to using the "catalog" approach?
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.