Previous Page | Next Page

SAS Component Language Dictionary

COPY



Copies a SAS table, view, catalog, or catalog entry
Category: Utility

Syntax
Details
Example
See Also

Syntax

sysrc=COPY(old-name,new-name<,type>);

sysrc

contains the return code for the operation:

0

successful

[ne]0

not successful

Type: Numeric

old-name

is the name of the SAS file or catalog entry to copy. This can be a one-, two-, or four-level name and can include SAS data set options.

Type: Character

new-name

is the new name for the SAS file or catalog entry. This must be a three- or four-level name if type is 'CATALOG'. If a catalog entry is being copied, the function sets the entry type of the new entry to that of the old entry. You can also specify SAS data set options.

Type: Character

type

is the type of SAS file or catalog entry to be copied:

'ACCESS'

The member is an access descriptor that was created using SAS/ACCESS software.

'CATALOG'

The member is a SAS catalog or a catalog entry.

'DATA'

The member is a SAS data file. (This is the default.)

'MDDB'

The member is an MDDB.

'VIEW'

The member is a SAS data view.

Type: Character


Details

To copy a catalog entry, specify the complete four-level name of the entry for old-name, a three-level name for new-name, and 'CATALOG' for type.

You can use the WHERE= data set option to copy only those rows that meet a WHERE subset to the new table.

The COPY function does not copy existing integrity constraints to the new SAS table. Use the ICCREATE function to define new integrity constraints.

If the SAS table that is being copied is indexed, then all indexes are rebuilt for the new SAS table. New-name is ignored when you use COPY to copy GRSEG catalog entries that were created using SAS/GRAPH software. A copied GRSEG entry will have either the same name as the original entry or, if an entry with that name already exists in the target catalog, a unique name generated by SAS software.

CAUTION:
This function can overwrite existing files.

If a table or catalog with the specified new name already exists, COPY overwrites the existing table or catalog without warning.  [cautionend]


Example

Copy the SAS table DATA1 to DATA2 and copy WORK.TEMP.A.SCL to SASUSER.PROFILE.B.SCL:

if (copy('data1','data2')) then
   do;
      _msg_=sysmsg();
      ...SCL statements to handle the
                 error condition...
   end;
rc=copy('work.temp.a.scl',
        'sasuser.profile.b.scl', 'catalog');
if (rc) then
   do;
      _msg_=sysmsg();
      ...SCL statements to handle the
                  error condition...
   end;

Copy from the SAS table SASUSER.CLASS to WORK.CLASS only those rows in which the variable GENDER=M:

if (copy('sasuser.class(where=(GENDER="M"))',
         'work.class')) then
   do;
      _msg_=sysmsg();
         ...SCL statements to handle the
         error condition...
   end;


See Also

DELETE

ICCREATE

RENAME

Previous Page | Next Page | Top of Page