COPY Procedure

Example 1: Copying SAS Data Sets between Hosts

Features:
PROC COPY statement options::
IN=
MEMTYPE=
OUT=
Other features:

XPORT engine

Details

This example illustrates how to create a transport file on a host and read it on another host.
In order for this example to work correctly, the transport file must have certain characteristics, as described in the SAS documentation for your operating environment. In addition, the transport file must be moved to the receiving operating system in binary format.

Program

libname source 'SAS-library-on-sending-host';

libname xptout xport 'filename-on-sending-host';
proc copy in=source out=xptout memtype=data;
   select bonus budget salary;
run;
 

Program Description

Assign library references.Assign a libref, such as SOURCE, to the SAS library that contains the SAS data set that you want to transport. Also, assign a libref to the transport file and use the XPORT keyword to specify the XPORT engine.
libname source 'SAS-library-on-sending-host';

libname xptout xport 'filename-on-sending-host';
Copy the SAS data sets to the transport file.
proc copy in=source out=xptout memtype=data;
   select bonus budget salary;
run;
 

1    LIBNAME source 'SAS-library-on-sending-host ';
NOTE: Libref SOURCE was successfully assigned as follows:
      Engine:        V9
      Physical Name: SAS-library-on-sending-host
2    LIBNAME xptout xport 'filename-on-sending-host';
NOTE: Libref XPTOUT was successfully assigned as follows:
      Engine:        XPORT
      Physical Name: filename-on-sending-host 
3    proc copy in=source out=xptout memtype=data;
4    select bonus budget salary;
5    run;

NOTE: Copying SOURCE.BONUS to XPTOUT.BONUS (memtype=DATA).
NOTE: The data set XPTOUT.BONUS has 1 observations and 3 variables.
NOTE: Copying SOURCE.BUDGET to XPTOUT.BUDGET (memtype=DATA).
NOTE: The data set XPTOUT.BUDGET has 1 observations and 3 variables.
NOTE: Copying SOURCE.SALARY to XPTOUT.SALARY (memtype=DATA).
NOTE: The data set XPTOUT.SALARY has 1 observations 

Enable the procedure to read data from the transport file.The XPORT engine in the LIBNAME statement enables the procedure to read the data from the transport file.
libname insource xport 'filename-on-receiving-host';
Copy the SAS data sets to the receiving host. After you copy the files (for example, by using FTP in binary mode to the Windows host), use PROC COPY to copy the SAS data sets to the WORK data library on the receiving host.
proc copy in=insource out=work;
run;
 

1     LIBNAME insource xport 'filename-on-receiving-host';
NOTE: Libref INSOURCE was successfully assigned as follows:
       Engine:      XPORT
       Physical Name: filename-on-receiving-host 
2     proc copy in=insource out=work;
3     run;
NOTE: Input library INSOURCE is sequential.
NOTE: Copying INSOURCE.BUDGET to WORK.BUDGET (memtype=DATA).
NOTE: BUFSIZE is not cloned when copying across different engines.
      System Option for BUFSIZE was used.
NOTE: The data set WORK.BUDGET has 1 observations and 3 variables.
NOTE: Copying INSOURCE.BONUS to WORK.BONUS (memtype=DATA).
NOTE: BUFSIZE is not cloned when copying across different engines.
      System Option for BUFSIZE was used.
NOTE: The data set WORK.BONUS has 1 observations and 3 variables.
NOTE: Copying INSOURCE.SALARY to WORK.SALARY (memtype=DATA).
NOTE: BUFSIZE is not cloned when copying across different engines.
      System Option for BUFSIZE was used.
NOTE: The data set WORK.SALARY has 1 observations and 3 variables.