Previous Page | Next Page

Functions and CALL Routines

RENAME Function



Renames a member of a SAS library, an entry in a SAS catalog, an external file, or a directory.
Category: External Files
Category: SAS File I/O
See: The RENAME Function under OpenVMS

Syntax
Arguments
Details
Examples
Example 1: Renaming Data Sets and Catalog Entries
Example 2: Renaming an External File
Example 3: Renaming a Directory
Example 4: Renaming a Generation Data Set
See Also

Syntax

RENAME(old-name, new-name <, type<, description <, password <, generation>>>>)


Arguments

old-name

specifies a character constant, variable, or expression that is the current name of a member of a SAS library, an entry in a SAS catalog, an external file, or an external directory.

For a data set, old-name can be a one-level or two-level name. For a catalog entry, old-name can be a one-level, two-level, or four-level name. For an external file or directory, old-name must be the full pathname of the file or the directory. If the value for old-name is not specified, then SAS uses the current directory.

new-name

specifies a character constant, variable, or expression that is the new one-level name for the library member, catalog entry, external file, or directory.

type

is a character constant, variable, or expression that specifies the type of element to rename. Type can be a null argument, or one of the following values:

ACCESS

specifies a SAS/ACCESS descriptor that was created using SAS/ACCESS software.

CATALOG

specifies a SAS catalog or catalog entry.

DATA

specifies a SAS data set.

VIEW

specifies a SAS data set view.

FILE

specifies an external file or directory.

Default: 'DATA'
description

specifies a character constant, variable, or expression that is the description of a catalog entry. You can specify description only when the value of type is CATALOG. Description can be a null argument.

password

is a character constant, variable, or expression that specifies the password for the data set that is being renamed. Password can be a null argument.

generation

is a numeric constant, variable, or expression that specifies the generation number of the data set that is being renamed. Generation can be a null argument.


Details

You can use the RENAME function to rename members of a SAS library or entries in a SAS catalog. SAS returns 0 if the operation was successful, and a value other than 0 if the operation was not successful.

To rename an entry in a catalog, specify the four-level name for old-name and a one-level name for new-name. You must specify CATALOG for type when you rename an entry in a catalog.

Operating Environment Information:   Use RENAME in directory-based operating environments only. If you use RENAME in a mainframe operating environment, SAS generates an error.  [cautionend]


Examples


Example 1: Renaming Data Sets and Catalog Entries

The following examples rename a SAS data set from DATA1 to DATA2, and also rename a catalog entry from A.SCL to B.SCL.

rc1=rename('mylib.data1', 'data2');
rc2=rename('mylib.mycat.a.scl', 'b', 'catalog');


Example 2: Renaming an External File

The following examples rename external files.

   /* Rename a file that is located in another directory. */
rc=rename('/local/u/testdir/first',
          '/local/u/second', 'file');
   /* Rename a PC file. */
rc=rename('d:\temp', 'd:\testfile', 'file');


Example 3: Renaming a Directory

The following example renames a directory in the UNIX operating environment.

rc=rename('/local/u/testdir/', '/local/u/oldtestdir', 'file');


Example 4: Renaming a Generation Data Set

The following example renames the generation data set WORK.ONE to WORK.TWO, where the password for WORK.ONE#003 is my-password.

rc=rename('work.one','two',,,3,'my-password'); 


See Also

Functions:

FDELETE Function

FILEEXIST Function

EXIST Function

Previous Page | Next Page | Top of Page