RENAME Function
Renames a member of a SAS library, an entry in a SAS catalog, an external file, or a directory.
| Categories: | External Files |
|---|---|
| SAS File I/O |
Table of Contents
Syntax
Required 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.
Optional Arguments
type
is a character constant, variable, or expression that specifies the type of element to rename. Type can be a null argument, or another value.
Here are valid 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.
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: