Wednesday, November 9, 2011

%INCLUDE SAS macro

SAS provides several methods to invoke external SAS macros in a SAS program. There are two that are most often used.


1 The first method is the autocall library, which enables users to invoke a macro that is not defined in the same SAS program. A user can designate one or more directories as a SAS autocall library to store macro source code. In most cases each macro file in a directory must contain a macro definition with a macro name that matches the filename.

options MAUTOSOURCE SASAUTOS=(C:\Documents and Settings\lhuang\Learning\SAS_practice\macro sasautos);

2 The second method is the %include statement, which identifies an entire external file that the user wants to bring into the program and execute immediately.

%include 'C:\Documents and Settings\lhuang\Learning\SAS_practice\macro\audit.sas';

%INCLUDE statement can be used whenever needed without requiring setting up an autocall library first. Also, it is simpler to use during program development. Autocall library is the best way to store well established macro source code, such as utility routines or shared macro(s) across protocols, which enables easy maintenance and better consistency when all macros are placed in one directory. 

No comments:

Post a Comment

Blog Archive