Example: COPY Procedure


Example 1: Copying SAS Data Sets between Hosts

Features:

  • PROC COPY statement options:

    • IN=

      MEMTYPE=

      OUT=

Other features: XPORT engine

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

Assign library references. Assign a libref, such as SOURCE, to the SAS data 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-data-library-on-sending-host  ';  libname xptout xport '  filename-on-sending-host  '; 

Copy the SAS data sets to the transport file. Use PROC COPY to copy the SAS data sets from the IN= library to the transport file. MEMTYPE=DATA specifies that only SAS data sets are copied . SELECT selects the data sets that you want to copy.

 proc copy in=source out=xptout memtype=data;     select bonus budget salary;  run; 

SAS Log

SAS Log on Sending Host

 1    libname source '  SAS-data-library-on-sending-host  ';  NOTE: Libref SOURCE was successfully assigned as follows:        Engine:        V9        Physical Name:  SAS-data-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 and 3 variables. 

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 NT 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; 

SAS Log on Receiving Host

 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. 



Base SAS 9.1.3 Procedures Guide (Vol. 1)
Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4
ISBN: 1590472047
EAN: 2147483647
Year: 2004
Pages: 260

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net