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 | |
| Restrictions: | If the SAS session in which you are specifying the FILEEXIST function is in a locked-down state, and the pathname specified in the function has not been added to the lockdown path list, then the function will fail and a file access error related to the locked-down data will not be generated in the SAS log unless you specify the SYSMSG function. |
| This function is not valid on the CAS server. |
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.
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 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
Examples
Example 1: Renaming Data Sets and Catalog Entries
rc1=rename('mylib.data1', 'data2');
rc2=rename('mylib.mycat.a.scl', 'b', 'catalog');Example 2: Renaming an External File
/* 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
rc=rename('/local/u/testdir/', '/local/u/oldtestdir', 'file');Example 4: Renaming a Generation Data Set
rc=rename('work.one', 'two',,, 3,'my-password');