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

I am creating a program that runs as part of my autoexec process flow.  I want to load the macros I will use during my EG project.

 

I have stored all my needed macros in one directory: C:\macros;

 

For example, one file in that directory might be macro_test.sas:

%macro test;

  %put Hello World;

%mend test;

 

How do I compile all the macros in that directory without using an %include statement for each program?

 

My first thought is:

options mautosource sasautos=("C:\macros\ ");

 

but when I then try to invoke %test I get the following error:  Apparent invocation of macro TEST not resolved.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

SASAUTOS is a good way to go, but ...

 

The most important change to make is that the name of the macro should match the name of the file holding the macro.  For example, the macro %test should be stored within test.sas (not within macro_test.sas).

 

It is possible you will need to change the path slightly to "C:\macros" rather than "C:\macros\ ".  You'll find out quickly enough whether that change is also needed.

 

Also note, if you encounter the issue you described, you must either restart the EG session or (better) issue this statement:

 

options MRECALL;

 

Otherwise, SAS stops searching for macros once a single search has failed.  This option restores the search process.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

SASAUTOS is a good way to go, but ...

 

The most important change to make is that the name of the macro should match the name of the file holding the macro.  For example, the macro %test should be stored within test.sas (not within macro_test.sas).

 

It is possible you will need to change the path slightly to "C:\macros" rather than "C:\macros\ ".  You'll find out quickly enough whether that change is also needed.

 

Also note, if you encounter the issue you described, you must either restart the EG session or (better) issue this statement:

 

options MRECALL;

 

Otherwise, SAS stops searching for macros once a single search has failed.  This option restores the search process.

LinusH
Tourmaline | Level 20
Just to verify: C:\macros is on the server (in case of a server based setup)?
Data never sleeps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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