Transferring SAS@Data Sets With The XCOpy Procedure

Tom Miron Systems Seminar Consultants, Madison, WI 608/222-7081

ABSTRACT It is often desirable to transfer SAS datasets There are a number of reasons to transfer SAS between different systems, between, say, a CMS datasets between an OS mainframe and a Pc. SAS mainframe computer and a pc. There are several provides PROC UPLOAD and DOWNLOAD to reasons why you may want to do this: facilitate this transfer. While UPLOAD and DOWNLOAD are convenient and relatively it's convenient to use the PC for straightforward they are not as efficient in terms of processing system resources as native file transfer programs such as IBM's IND$FILE. This efficiency difference there may be output devices that are only can be significant when transferring large SAS available on the host system or on your PC datasets. In addition, UPLOAD and DOWNLOAD work via interactive SAS on the host system. Users your SAS based application may have with limited access to interactive SAS may not be outgrown the capacity of your PC able use UPLOAD and DOWNLOAD to transfer files. the source of your data may have changed.

This paper describes an alternative method of There are a couple ways to transfer SAS datasets transferring SAS datasets using PROC XCOPY on the between systems. The most familiar is probably host end, and PROC and LlBNAME with the the use of PROC UPLOAD and PROC SASV5XPT option on the PC end. Actual data DOWNLOAD. These PROC's allow the direct transfer is accomplished with the system native file transfer of datasets from one system to another. transfer program. This method of copying SAS Unfortunately, UPLOAD/DOWNLOAD may not be datasets from the host to PC allows for minimum available to all SAS users. cost and allows users that do not have access to interactive SAS on the host to use host data on their If foreground SAS is not available on your host PC's. The method can be useful in certain data computer system you cannot use gathering applications as well. UPLOAD/DOWNLOAD. These PROC's require a link between concurrent SAS sessions on the host and a pc.

What, Why, How? Some users may have foreground SAS available on the host but do not have a communications link This paper describes a method for transferring SAS between the PC and the host that is supported by datasets between mainframe or mini computers the SAS RLiNK software. In either case you can running SAS 5 and PC's running SAS Ver 6.03. still transfer SAS datasets via the XCOPY method described below.

922 This method can also be useful for transferring There are three things to note here: large amounts of data since it uses "native" file transfer methods that are usually faster than 1 . use the EXPORT option on PROC UPLOAD/DOWNLOAD. XCOpy

2. make sure the OUT = file is defined The XCOPY Method as RECFM F (record is fixed) and lRECL 80 (record length is 80 The XCOPY method for transferring SAS datasets characters or bytes) requires only that you have SAS Ver S running on 3. you can select SAS datasets to your host system, have PC SAS Ver 6 on your PC, XCOpy into the transport library and have a means of transferring files between the with the SELECT statement. two. This file transfer method must support binary transfer. Binary transfer simply means that the You must use these RECFM and LRECL options transfer software does not attempt to change or (RECFM of FB, fixed block, is also acceptable). translate the data in any way: no translation from EBCDIC to ASCII (or vice versa) and no insertion of carriage return and linefeed (CRLF) characters File Transfer the end of "lines" of data. After running the XCOPY SAS program you will The XCOPY method relies on 2 features of the SAS have a SAS "transport" format dataset in a file system: named HOST DATA A. The next step is to transfer this to your Pc. 1. PROC XCOPY 2. the SASV5XPT option of the LlBNAME If you are using the IBM IND$FILE transfer progr

Let's see how it works ... RECEIVE C:\TRANS.DAT HOST DATA A

Downloading with XCOPY on your Pc. This command will transfer HOST DATA A to a PC file called TRANS.DAT in the root The examples used below are for an IBM CMS of the C: drive. For those familiar with host system but would be similar for IBM MVS/OS the IND$FILE SEND and RECEIVE command, note system and mini computer hosts. For MVS that you do not use the ASCII and CRlF substitute TSO ALlOC or JCL DD statements for parameters ... this is a binary file transfer. CMS FILEDEF's. You can use any PC file name. The first step is to translate your host SAS datasets to the transport format: You can use any file transfer method (your site may not have IND$FllE SEND and RECEIVE. The CMS FILEDEF TRANS DISK only requirement is that the file transfer you do use HOST DATA A (RECFM F LRECL 80; is capable of a binary file transfer. PROC XCOPY IN=SASDATA OUT=TRANS EXPORT; SELECT MYDS; /* optional */ RUN;

923 to PC SAS make a transport format. copy of the dataset in the MS-DOS file TRANS.DAT in the root directory of The final step is to convert the transport dataset the C: drive. downloaded from the host into a standard Ver 6 SAS dataset. The following program, run on the Again, you can use any DOS file name or libname PC that received the transport dataset from the you want, and you can SELECT one or more host, will do the conversion: datasets from a library. The important thing is the use of SASV5XPT and the use of a full FILESPEC LIBNAME FROMHOST SASV5XPT when defining the output libname. 'C:\TRANS.DAT' ; LIBNAME MYLIB 'C:\SSD'; Transfer up PROC COpy IN=FROMHOST OUT=MYLIB; The next upload step is file transfer. An example: SELECT MYDS; /* optional */ RUN; SEND C:\TRANS.DAT HOST DATA A (RECFM F LRECL 80 There are four things to note about this program: And again, note that you do not specify the ASCII or CRLF parms. You do specify the RECFM F and 1. use the SASV5XPT option on the LlBNAME LRECL 80 parms if you are creating a new dataset statement on the host via the file transfer. If you do not use IND$FILE SEND and RECEIVE just make sure you 2. the input libname points at an MS-DOS specify a binary file transfer for the method you do FILESPEC not a directory use and insure that the receiving file on the host has a RECFM of F and LRECL of 80. 3. you can select individual datasets from several that may be in the transport library Converting uploads to Ver 5 4. you can use any valid libname you like. The following program, run on the host system that received the uploaded transport library, will Uploading convert that library into the standard SAS Ver 5 format: Uploading SAS datasets from the PC to a host system is essentially the same process in reverse. CMS FILEDEF FROMPC DISK HOST DATA A; First, convert a PC SAS dataset(s) to the transport format: PROC XCOPY IN=FROMPC OUT=MYLIB IMPORT; LI BNAME FROMPC SASV5XPT SELECT SOMEDATA; 'C:\TRANS.DAT' ; RUN; LIBNAME MYLIB 'C:\SSD'; Note the use of the IMPORT option with PROC XCOPY and the fact that you can SELECT datasets PROC COpy IN=MYLIB OUT=FROMPC; from the transport library. SELECT SOMEDATA; RUN; This program, run on the PC holding the dataset you want to upload (MYLlB.50MEDATA), will

924 Rules SAS documentation

When using the XCOPY method remember these "SAS Language Guide for Personal Computers rules: Release 6.03"

1 . Use PROC XCOPY on the host and PROC pages 514-515 COPY on the pc. LlBNAME with the SASV5XPT option 2. When sending datasets from the host to the PC use the PROC XCOPY option EXPORT.

3. When receiving datasets from the PC on the "SAS Procedures Guide Release 6.03" host use the PROC XCOPY option IMPORT. pages 121-124 4. The transport library on the host system must be RECFM F and LRECL 80, i.e., fixed record PROC COPY format and record length of 80. "SAS User's Guide: Basics Version 5 Edition"

5. Always use binary file transfer. No ASCII pages 1193-1199 translation or CRLF insertions. PROC XCOPY 6. On the PC always use the SASV5XPT option on the LlBNAME statement that defines the transport format library.

7. The LlBNAME statement that defines the transport format library on the PC (imported or exported) must point at a full DOS FILESPEC not just a directory as with the standard usage.

ZAPS may be required!

You may have to apply the following ZAPS to SAS Ver 6.03 before using the XCOPY method:

if transferring to or from an MVS/OS host

Z6030870

if transferring from a VMS host

Z6030988

925