DATASETS Procedure

EXCHANGE Statement

Exchanges the names of two SAS files in a SAS library.
Manipulating SAS Files

Syntax

Required Argument

name=other-name
exchanges the names of SAS files in the procedure input library. Both name and other-name must already exist in the procedure input library.

Optional Arguments

ALTER=alter-password
provides the Alter password for any alter-protected SAS files whose names you want to exchange. You can use the option either in parentheses after the name of each SAS file or after a forward slash.
MEMTYPE=mtype
restricts processing to one member type. You can exchange only the names of SAS files of the same type. You can use the option either in parentheses after the name of each SAS file or after a forward slash.
Default:If you do not specify MEMTYPE= in the PROC DATASETS statement, the default is ALL.

Details

When you exchange more than one pair of names in one EXCHANGE statement, PROC DATASETS performs the exchanges in the order in which the names of the SAS files occur in the directory listing, not in the order in which you list the exchanges in the EXCHANGE statement.
If the name SAS file does not exist in the SAS library, PROC DATASETS stops processing the RUN group that contains the EXCHANGE statement and issues an error message. To override this behavior, specify the NOWARN option in the PROC DATASETS statement.
The EXCHANGE statement also exchanges the associated indexes so that they correspond with the new name.
The EXCHANGE statement only allows two existing generation groups to exchange names. You cannot exchange a specific generation number with either an existing base version or another generation number.