How do I transfer mainframe data to a non-mainframe platform?
The CPORT and CIMPORT procedures can be used to transfer mainframe-based WPD data libraries to another platform. If you need to transfer other types of libraries such as custom formats or special compiled macros, you will need to rebuild them from source on the destination platform.
The portable SAS language method of doing this is to use the CPORT and CIMPORT procedures. Create a portable copy using the CPORT procedure and transfer the resulting file in BINARY mode, with no CRLF characters etc., to your destination platform. When the file has been transferred, use the CIMPORT procedure to load the file into a new target library.
Example Jobstream to create the cport file on a mainframe:
// <job statement>
//<stepname> EXEC WPSPROC
//INLIB DD DSN=<input library name>,DISP=OLD
//CPORT DD DSN=<transfer file name>,
// DISP=(NEW,CATLG,DELETE),SPACE=(<however much is necessary>)
//SYSIN DD *
PROC CPORT LIBRARY=INLIB FILE=CPORT;
RUN;
You would need to insert your own values into <…> expressions above.
Example script to read in a cport file in windows:
libname newlib clear;
filename tranfile clear;
libname newlib '<wherever the target library is intended to be>';
filename tranfile '<wherever the portable file was sent to>';
proc cimport library=newlib infile=tranfile;
run;
Transfer the mainframe library to the windows machine using the FTP engine. Following transfer the resulting file must be read into the windows version of Altair SLC using the WPDFILE engine.
Example script to transfer a mainframe library and load into the windows platform:
data _null_;
filename temp clear;
filename source clear;
filename source ftp "'<dsn of input data library>'"
host='<hostname or IP address of mainframe system>'
user='<userid>'
pass='<password>'
pasv
recfm=n
binary
rcmd='site lrecl=27648 blksize=27648 recfm=F';
filename temp '<path and name of an intermediate file>'
recfm=F
lrecl=27648;
data _null_;
*
* this step reads the mainframe-based data library as a 'flat' file, ignoring
* the WPD data library structure;
*
infile source lrecl=27648;
file temp;
input;
put _infile_;
run;
data _null_;
*
* Having read the data library into a temporary place, it must now be read
* using the 'wpdfile' engine. This engine is only applicable to data
* libraries, so the previously-specified 'filename' statement that points to
* the temporary file must be released before the necessary 'libname'
* statement can be specified.
*
filename temp clear;
libname lib wpdfile '<same path and name of intermediate file specified above>'
libname pdb '<final path and name of the target data library>';
proc copy out=pdb in=lib;
*
* This 'proc copy' will detect and correct ENCODING problems, etc. Expect
* to see logged messages like:
* NOTE: Data set LIB.CPU either has a foreign data representation, or the encoding does not match the session encoding
* NOTE: Byte order is foreign
* NOTE: Floating point representation is foreign
* NOTE: Char representation open_ed-1047 is not compatible with session encoding of wlatin1
run;
** N.B. The 'lrecl' values specified in the above code MUST match the LRECL of the mainframe-based data library **