Help using Base SAS procedures

Question on %include and Macros

Frequent Contributor
Posts: 117

Question on %include and Macros

Hi Guys,

I have created an automation SAS file that calls/runs another SAS file in a specific directory. Here is my question:

File1.SAS --> This is my automation file that contains a few macros for directory locations. I use the following include statement in this file:

%include "&driv.\&path1.\&";

File2.SAS --> This is the main SAS file I run using File1.SAS. It also contains a few macros that need to be updated before running.

My Question: If I move the macros from File2.SAS to File1.SAS will it cause any problems? The main reason I want to do this is because I want to update my macros only in 1 file and not open 2 seperate files each month to update.


Super Contributor
Posts: 356

Question on %include and Macros

Assuming when you say moving the macors, your are talking about moving the macro varable assignments and/or macro code , you shouldn't have any issues.... 


Super User
Posts: 6,785

Question on %include and Macros

Technically, you won't have any problems.

In practice, it's usually done another way.  Look up and read about "autocall libraries".

There are a few reasons your approach becomes cumbersome in the long run.  First, as your list of macros becomes longer and longer, the logs of all your programs become longer and longer as well.  Much of the log will get consumed by defining macros that are never used in that particular program.  This approach also makes it harder for the user to inspect the first file with all the macros and figure out what he needs to know and what he can ignore.  Finally, each program will waste a little CPU time by defining macros not needed in that particular program.

If you do set up an autocall library, you can even stick the libname definitions inside a macro as well.  The user's program might look something like this:

options sasautos='path to autocall library';


** add the rest of the program, using any macros that are part of the autocall library;

You'll need to do your own homework and reading, though.  Good luck.

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation