BookmarkSubscribeRSS Feed
shl007
Obsidian | Level 7

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!

7 REPLIES 7
Astounding
PROC Star

There's plenty of information out there.  Did you try googling "autocall"?

 

Basics:

 

http://support.sas.com/documentation/cdl/en/mcrolref/62978/HTML/default/viewer.htm#n1o5fkxq0gqdpcn1x...

 

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.

shl007
Obsidian | Level 7

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.

Astounding
PROC Star

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.

shl007
Obsidian | Level 7

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:

 

  1. Use a LIBNAME statement to assign a libref to the SAS library.

     

  2. Use a FILENAME statement with the CATALOG argument to assign a fileref to the catalog that contains the autocall macros. For example, the following code creates a fileref, MYMACROS, that points to a catalog named MYMACS.MYAUTOS:
    libname mymacs 'SAS-data-library';
    filename mymacros catalog 'mymacs.myautos';

     

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

     

  4. Set the SASAUTOS system option to specify the fileref as an autocall library. For more information, see SASAUTOS in Chapter 13.

 

 

Astounding
PROC Star

Yes, for most programmers, that is overkill.  Here's the simpler way (tailored for PCs):

 

http://support.sas.com/kb/24/451.html

 

 

Patrick
Opal | Level 21

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.

https://go.documentation.sas.com/?docsetId=mcrolref&docsetTarget=p12b2qq72dkxpsn1e19y57emerr6.htm&do...

shl007
Obsidian | Level 7

Can anyone explain any advantages to using the "catalog" approach?

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 7 replies
  • 1680 views
  • 0 likes
  • 3 in conversation