|Moving and Accessing SAS Files across Operating Environments|
You can specify file attributes through either the FILENAME statement or the FTP utility.
Note: Releases 6.11 through Version 8 support the FILENAME
statement with the FTP access method, which specifies file attributes for
file transfer. Releases prior to 6.11 do not support the FILENAME statement
with the FTP access method.
|Using the FILENAME Statement to Specify File Attributes for All Hosts|
Here is an example of using the FILENAME statement with the FTP access method to specify file attributes and to transfer a transport file over the network to a target host:
filename tranfile ftp 'tport.dat' lrecl=80 blocksize=8000 recfm=f cd='mydir' host='myhost.mycompany.com' user='myuser' pass='mypass' rcmd='site umask 022' recfm=s;
In this example, the FILENAME statement specifies the fileref TRANFILE, which points to the external file TPORT.DAT for transfer over the network. FTP options specify values for the record attributes: record length, block size, and record format. Also, FTP options identify the location for the file transfer on the target host and the userid and password that permit access to the target host. Finally, the file mode creation mask on the target host and a binary transfer are specified. For complete details about the FILENAME statement with the FTP access method, see SAS Language Reference: Dictionary and the companion that is appropriate to your operating environment. For an example of using the FILENAME statement with the FTP access method, see OS/390 TSO to UNIX File Transport.
|Using FTP to Transfer a File across the Network|
FTP is a user interface to the File Transfer Protocol. FTP copies files across a network connection between the source host and a target host. FTP runs from the initiating host, which can be either the source host or the target host.
In order to transfer a file to a target host across a network, ensure that a binary (or image) format transfer is specified. This format guarantees a consistent file structure for any operating environment that runs SAS. For example, you must use the FTP BINARY command to declare binary format. For typical FTP command syntax, see Example of Using FTP to Transfer Transport Files.
Transferring a file in ASCII format places extra characters in the transport file on the target host. These characters are typically line feeds, carriage returns, end-of-record markers, and other characters that some operating environments use to define file characteristics.
Target hosts that run SAS expect a transport file to be formatted in a certain structure, without these characters. The introduction of these characters into a file causes corruption, which prevents the file from being successfully restored at the target host. Error messages usually warn of file corruption. For information about file corruption and how to recover from this condition, see Preventing and Fixing Problems.
|Transferring a Transport File by Using a Magnetic Medium|
When transporting a file by means of tape, always use an unlabeled tape. Although using a standard labeled tape is possible, it usually requires extra work to read the file at the target host.
Also, if the transport file exceeds the capacity of one tape, then problems may occur during the restoration process. Rather than using multi-volume tapes, you should divide the original library into two or more libraries and create a separate tape for each one. The original library can be rebuilt at the target host.
At the source host, use the LIBNAME statement to assign the transport file to a magnetic medium. Here are two examples:
|UNIX||libname tranfile xport '/dev/tape';|
|Windows||libname tran xport 'a:\test';|
Specification of the file path varies by host.
The method used to move the transport file to a physical tape varies by host. Here is a UNIX example:
dd if=tranfile of=/dev/tape1 bs=8000;The UNIX
ddcommand copies the specified input file to the specified output device. Block size is 8000.
At the target host, you must copy the transport file from tape to disk. Here is a UNIX example:
dd if=/dev/tape1 of=tranfile bs=8000;
At the target host, you use the LIBNAME statement to translate the transport file to native format, assigning the resulting translated file to a specific file location. Here is a UNIX example:
libname tranfile xport '/dev/tape1';
For host-dependent details about using tape devices, see the appropriate chapter in Part 5 and the companion documentation that is appropriate to your operating environment.
|Example of Using FTP to Transfer Transport Files|
In the following examples, TRANFILE specifies the name of the transport file that is transferred across the network. TARGET specifies the destination for the transport file on the target host.
Typical FTP PUT Commands shows the typical FTP commands used at the source host to put a transport file on the target host:
Typical FTP PUT Commands
/* putting transport file on the target host */ > open target-host > binary > put tranfile target-host-filename > close > quit
Typical FTP GET Commands shows the typical FTP commands used at the target host to get a transport file from the source host:
Typical FTP GET Commands
/* At the source host, getting transport file from */ /* the target host */ > open target-host > binary > get tranfile source-host-filename > close > quit
If you have access to a UNIX system, see the
ftp(1) manual page for more details.
In order to copy a file with
put command to a remote host
location, you must have write permission to the target location on the remote
host. Because a local user's permission to put a file at a remote host location
is uncertain, it is recommended that the remote user use the FTP
get command to obtain the file from the local
host instead. The local user must grant read and write permission to the file
that the remote user accesses.
The following code shows an example of user JOE at the target host getting two transport files from an OpenVMS Alpha source host:
Typical FTP Session
 hp> ftp myhost.mycompany.com Connected to myhost.mycompany.com 220 myhost.mycompany.com MultiNet FTP Server Process V4.0(15) at Mon 28-Sep-98 12:59PM-EDT Name (myhost.mycompany.com:): joe 331 User name (joe) ok. Password, please. Password: 230 User JOE logged into DISK01:[JOE] at Mon 28-Sep-98 12:59PM-EDT, job 27a34cef. Remote system type is VMS.  ftp> cd [.xpttest] 250 Connected to DISK01:[JOE.XPTTEST].  ftp> binary 80 200 Type I ok.  ftp> get xptds.dat xptds.dat 200 Port 14.83 at Host 10.26.2.45 accepted. 150 IMAGE retrieve of DISK01:[JOE.XPTTEST]XPTDS.DAT;1 started.  226 Transfer completed. 1360 (8) bytes transferred. 1360 bytes received in 0.02 seconds (87.59 Kbytes/s)  ftp> get xptlib.dat xptlib.dat 200 Port 14.84 at Host 10.26.2.45 accepted. 150 IMAGE retrieve of DISK01:[JOE.XPTTEST]XPTLIB.DAT;1 started.  226 Transfer completed. 3120 (8) bytes transferred. 3120 bytes received in 0.04 seconds (85.81 Kbytes/s)  ftp> quit
|Using FTP to Transfer a File That Was Created with CEDA Features|
You transfer a file that was created with CEDA features in the same way that you transfer a transport file. The only difference between the two is the filename. SAS appends a transport filename with an appropriate member type extension, such as .DAT for a data set. A file that was created with CEDA features is appended with an appropriate Version 8 filename extension; for example, .SAS7BDAT for a data set.
Top of Page
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.