Macros for SAS Application Developers
No Matches File Reference

Performs a wrapped %include. More...

Go to the source code of this file.

Detailed Description

This macro wrapper is necessary if you need your included code to know that it is being %included.

If you are using include in a regular program, you could make use of the following macro variables:


However these variables are NOT available inside a macro, as documented here:

This macro can be used in place of the include statement, and will insert the following (equivalent) global variables:


These can be used whenever testing within a macro. Outside of the macro, the regular automatic variables will still be available (thanks to a concatenated file list in the include statement).

Example usage:

filename example temp;
data _null_;
  file example;
  put '%macro test();';
  put '%mend; %test()';
[in]filerefThe fileref of the file to be included. Must be provided.
[in]prefix=(_) The prefix to apply to the global variables.
[in]opts=(SOURCE2) The options to apply to the inc statement
[in]errds=(work.mp_abort_errds) There is no clean way to end a process within a include called within a macro. Furthermore, there is no way to test if a macro is called within a include. To handle this particular scenario, the mp_abort() macro will test for the existence of the _SYSINCLUDEFILEDEVICE variable and return the outputs (msg,mac) inside this dataset. It will then run an abort cancel FILE to stop the include running, and pass the dataset back.

IMPORTANT NOTE - it is NOT possible to read this dataset as part of this macro! When running abort cancel FILE, ALL macros are closed, so instead it is necessary to invoke "%mp_abort(mode=INCLUDE)" OUTSIDE of macro wrappers.

Allan Bowe

SAS Macros

Definition in file