Chapter Contents

Previous

Next
SAS Library: _copyMember

SAS Library: _copyMember



Copies a library member


Syntax
Examples
Example 1: Copying a Member
Example 2: Creating a New SAS Catalog Object with _copyMember
Example 3: Creating a SAS Data File Object with _copyMember

Syntax

CALL SEND (library-object-id, '_copyMember', source-member-name, target-libref<, member-type><, new-object-id>);

Argument Type Description
source-member-name
C specifies the SAS data file or catalog that will be copied; must be a one-level name
target-libref
C specifies the libref of the target library for the copy
member-type
C specifies the member type:
'DATA' (the default)
'CATALOG'
'VIEW'
'ACCESS'
new-object-id
N if included, returns the object identifier for the new object associated with target-member-name. If you are copying a catalog, the new-object-id will be a SAS Catalog object. If you are copying a SAS data file, new-object-id will be a SAS Data File object. If the copy fails, the value of new-object-id is 0.


Examples

Example 1: Copying a Member

Suppose that the library associated with the LIBOBJ2 SAS Library object contains a catalog named GSEG and a data set named COSTS:

( ( LIBNAME='LIB'
    MEMNAME='COSTS'
    MEMTYPE='DATA'
   )[2645]
  ( LIBNAME='LIB'
    MEMNAME='GSEG'
    MEMTYPE='CATALOG'
   )[2647]
 )[2639]

This example copies the GSEG catalog to a new catalog, NEWCAT, in LIBOBJ2:

libclass=loadclass
         ('sashelp.fsp.library.class');
libobj2=instance(libclass);
call send(libobj2, '_assign_', 'lib',
          'pathname');
call send(libobj2, '_copy_member_', 'gseg', 
          'newcat', 'catalog');

Use _loadMembers to get the members associated with LIBOBJ2:

call send(libobj2, '_load_members_',
          memberlist);

If you list the contents of MEMBERLIST, you see that NEWCAT has been added:

( ( LIBNAME='LIB'
    MEMNAME='COSTS'
    MEMTYPE='DATA'
   )[2647]
  ( LIBNAME='LIB'
    MEMNAME='GSEG'
    MEMTYPE='CATALOG'
   )[2645]
  ( LIBNAME='LIB'
    MEMNAME='NEWCAT'
    MEMTYPE='CATALOG'
   )[2661]
 )[2639]

Example 2: Creating a New SAS Catalog Object with _copyMember

This example copies the GSEG catalog to a new catalog, NEWCAT2, in LIBOBJ2 and creates a SAS Catalog object, CATOBJ:

libclass=loadclass
         ('sashelp.fsp.library.class');
libobj2=instance(libclass);
call send(libobj2, '_assign_', 'lib',
          'pathname');
call send(libobj2, '_copy_member_', 'gseg',
          'newcat2', 'catalog', catobj);

If you use PUTLIST to list the contents of CATOBJ, you see that it is associated with LIB.NEWCAT2:

( _class=2649
  DESC='SAS Catalog Class'
  FULLNAME='LIB.NEWCAT2'
  LIBRARY=<invalid list id>[0]
  ATTRIBUTES=<invalid list id>[0]
 )[2663]

In addition, if you use _loadMEMBERS to get the members associated with LIBOBJ2, you see that NEWCAT2 has been added to the library:

( ( LIBNAME='LIB'
    MEMNAME='COSTS'
    MEMTYPE='DATA'
   )[2661]
  ( LIBNAME='LIB'
    MEMNAME='GSEG'
    MEMTYPE='CATALOG'
   )[2645]
  ( LIBNAME='LIB'
    MEMNAME='NEWCAT'
    MEMTYPE='CATALOG'
   )[2647]
  ( LIBNAME='LIB'
    MEMNAME='NEWCAT2'
    MEMTYPE='CATALOG'
   )[2667]
 )[2639]

Example 3: Creating a SAS Data File Object with _copyMember

If you copy the COSTS data set, a SAS Data File object is created. This example copies COSTS to NEWDATA and creates the SAS Data File object, DFILEOBJ:

call send(libobj2, '_copy_member_', 'costs',
          'newdata', 'data', dfileobj);

If you list the contents of DFILEOBJ, you see that this SAS Data File object is associated with LIB.NEWDATA:

( _class=2669
  DESC='SAS Datafile Class'
  TYPE=''
  FULLNAME='LIB.NEWDATA'
  LIBRARY=<invalid list id>[0]
  ATTRIBUTES=<invalid list id>[0]
  MEMTYPE='DATA'
 )[2675]

In addition, if you use _loadMEMBERS to get the members associated with LIBOBJ2, you see that NEWDATA has been added:

( ( LIBNAME='LIB'
    MEMNAME='COSTS'
    MEMTYPE='DATA'
   )[2667]
  ( LIBNAME='LIB'
    MEMNAME='GSEG'
    MEMTYPE='CATALOG'
   )[2647]
  ( LIBNAME='LIB'
    MEMNAME='NEWCAT'
    MEMTYPE='CATALOG'
   )[2645]
  ( LIBNAME='LIB'
    MEMNAME='NEWCAT2'
    MEMTYPE='CATALOG'
   )[2661]
  ( LIBNAME='LIB'
    MEMNAME='NEWDATA'
    MEMTYPE='DATA'
   )[2681]
 )[2639]


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.