Process to Execute a Stored Compiled DATA Step Program
To execute a stored compiled DATA step program, follow these steps:
1. Write a DATA step for each execution of the stored program. In this DATA step,
specify the name of the stored program in the PGM= option of the DATA statement
and include an optional password. You can do any of the following tasks:
• Submit this DATA step as a separate program.
• Include it as part of a larger SAS program that can include other DATA and
procedure (PROC) steps.
• Point to different input and output SAS data sets each time you execute the stored
program by using the REDIRECT statement.
2. Submit the DATA steps. Be sure to end each one with a RUN statement or other step
boundary.
Using Global Statements
You can use global SAS statements such as FILENAME or LIBNAME when you store
or execute a stored compiled DATA step program. However, the global statements that
you use to compile and store a DATA step program are not stored with the DATA step
code.
Redirecting Output
You can redirect external files using filerefs. You can use the REDIRECT statement for
renaming input and output SAS data sets.
You can use the REDIRECT statement to redirect input and output data to data sets you
specify. Note that the REDIRECT statement is available only for use with stored
compiled DATA step programs.
Note: To redirect input and output stored in external files, include a FILENAME
statement at execution time to associate the fileref in the source program with
different external files.
CAUTION:
Use caution when you redirect input data sets. The number and attributes of
variables in the input SAS data sets that you read with the REDIRECT statement
should match those of the input data sets in the SET, MERGE, MODIFY, or
UPDATE statements of the source code. If they do not match, the following occurs:
• If the variable length attributes differ, the length of the variable in the source code
data set determines the length of the variable in the redirected data set.
• If extra variables are present in the redirected data sets, the stored program stops
processing, and an error message is sent to the SAS log.
• If the variable type attributes are different, the stored program stops processing, and
an error message is sent to the SAS log.
684 Chapter 28 • Stored Compiled DATA Step Programs