Previous Page | Next Page

SAS Component Language Dictionary

RENAME



Renames a member of a SAS data library, an external file, or a directory
Category: Utility

Syntax
Details
Mainframe Usage of RENAME
Examples
Example 1: Renaming Tables and Catalog Entries
Example 2: Renaming an External File
Example 3: Renaming a Directory
Example 4: Renaming a Data Set Generation
See Also

Syntax

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

sysrc

contains the return code for the operation:

Type: Numeric

0

successful

[ne]0

not successful

old-name

is the current name of a member of a SAS data library, an external file, or an external directory. For a member, this can be a one-, two-, or four-level name. For an external file or a directory, old-name must be the full pathname of the file or a directory; otherwise, the current directory is used.

Type: Character

new-name

is the new one-level name for the library member, external file, or directory.

Type: Character

type

specifies the type of element to rename:

Type: Character

'ACCESS'

an access descriptor that was created using SAS/ACCESS software

'CATALOG'

a SAS catalog or catalog entry

'DATA'

a SAS table (This is the default.)

'VIEW'

a SAS table view

'FILE'

an external file or a directory.

description

is the description of a catalog entry. You can specify description only when type is CATALOG.

Type: Character

password

is the password for the file that is being renamed.

Type: Character

generation

is the generation number of the data set that is being renamed.

Type: Numeric


Details

You can use RENAME to rename files or directories that are external to a SAS session as well as members of a SAS data library.

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 renaming an entry in a catalog.


Mainframe Usage of RENAME

RENAME works on directory-based operating systems only. RENAME was not designed for mainframe operating systems, and will produce the following error:

ERROR: Requested function is not supported.

To rename external files or directories on a mainframe, use the host command for renaming files in conjunction with the SYSTEM function. For example, on MVS you could use the following:

 rc=system("rename 'userid.old.lib' 'userid.new.lib'");


Examples


Example 1: Renaming Tables and Catalog Entries

Rename a SAS table from DATA1 to DATA2. 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

Rename an external file:

   /* rename a file that is 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

Rename a directory:

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


Example 4: Renaming a Data Set Generation

Rename a generation of the data set work.one to work.two , where the password for work.one#003 is "joyful":

rc=rename('work.one','two','data',",'joyful',3);


See Also

DELETE

Previous Page | Next Page | Top of Page