Chapter Contents

Previous

Next
REDIRECT

REDIRECT



Points to different input or output SAS data sets when you execute a stored program

Valid: in a DATA step
Category: Action
Type: Executable
Requirement: You must specify the PGM= option in the DATA statement.


Syntax
Arguments
Details
Comparison
Examples
See Also

Syntax

REDIRECT INPUT | OUTPUT old-name-1 = new-name-1<. . . old-name-n = new-name-n>;

Arguments

INPUT | OUTPUT
specifies whether to redirect input or output data sets. When you specify INPUT, the REDIRECT statement associates the name of the input data set in the source program with the name of another SAS data set. When you specify OUTPUT, the REDIRECT statement associates the name of the output data set with the name of another SAS data set.

old-name
specifies the name of the input or output data set in the source program.

new-name
specifies the name of the input or output data set that you want SAS to process for the current execution.


Details

The REDIRECT statement is available only when you execute a stored program. For more information about stored programs, see the "Stored Compiled DATA Step Programs" chapter of SAS Language Reference: Concepts.

CAUTION:
Use care when you redirect input data sets. The number and attributes of variables in the input data sets that you read with the REDIRECT statement should match those of the input data sets in the MERGE, SET, MODIFY, or UPDATE statements of the source code. If the variable type attributes differ, the stored program stops processing and an appropriate error message is sent to the SAS log. 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. Extra variables in the redirected data sets do not cause the stored program to stop processing, but the results may not be what you expect.  [cautionend]


Comparison

The REDIRECT statement applies only to SAS data sets. To redirect input and output stored in external files, include a FILENAME statement to associate the fileref in the source program with different external files.


Examples

This example executes the stored program called STORED.SAMPLE. The REDIRECT statement specifies the source of the input data as BASE.SAMPLE. The output data set from this execution of the program is redirected and stored in a data set named SUMS.SAMPLE.

libname stored 'SAS-data-library';
libname base 'SAS-data-library';
libname sums 'SAS-data-library';

data pgm=stored.sample;
   redirect input in.sample=base.sample;
   redirect output out.sample=sums.sample;
run;

See Also

Statement:

DATA

"Stored Compiled DATA Step Programs" in SAS Language Reference: Concepts


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.