Examples of Moving SAS Files |
Restoring the Transport File at the Source Computer |
Use the appropriate strategy (PROC COPY or PROC CIMPORT) to restore the transport file to your source computer. A successful translation of the transport file to native format on the source computer verifies the integrity of the transport file to be transferred.
This example shows the creation of a transport file:
libname xptlib xport 'xptlib.dat'; /* create a transport file for the entire library */ proc copy in=work out=xptlib; run;
PROC COPY reads the library from the libref WORK and writes the transport file to the libref XPTLIB.
This example restores the transport file that was just created to the source computer:
libname test 'test'; /* restore the transport file at the source computer */ proc copy in=xptlib out=test; run;
The value for the OUT= option in the example that creates the transport file becomes the value for the IN= option in the example that restores the transport file to the source computer. To protect against overwriting the original data library that is created in WORK, direct output to the library TEST. The transport file is read from the libref XPTLIB and restored to the libref TEST in native format by PROC COPY.
For complete details about the syntax for these procedures, see the Base SAS Procedures Guide.
Verify the outcome of this test by viewing the SAS log at the source computer. If the transport operation succeeded at the source computer, then you can assume that the transport file content is correct. If the transport operation failed, then you can assume that the transport file was not created correctly. In this case, re-create the transport file and restore it again at the source computer.
Verifying the Size of a Transport File |
Use your operating environment's list command to verify that the transport file was successfully created. Here is an OpenVMS example:
vms> dir/size=all *dat Directory HOSTVAX:[JOE.XPTTEST] XPTDS.DAT;1 7/8 XPTLIB.DAT;1 7/8
The sizes of both files are 7/8 of a block, which is equivalent to 448 bytes.
$ ls -l *dat -rw-r--r-- 1 joe mkt 448 Oct 13 14:24 xptds.dat -rw-r--r-- 1 joe mkt 890 Oct 13 14:24 xptlib.dat
The size of XPTDS.DAT is 448 bytes; XPTLIB.DAT is 890 bytes.
The method for listing a file size varies according to operating environment.
Compare the size of the transport file on the source computer with the size of the transport file that is transferred to the target computer. If the sizes of the transport files are identical, then you can assume that the network successfully transferred these files. If the sizes are not the same, you can assume that the network transfer failed. In this case, review the transfer options and try the transfer again.
Comparing the Original Data Set with the Restored Data Set |
You can use the CONTENTS procedure to reveal discrepancies between the original data set at the source computer and the restored data set at the target computer. A comparison could reveal a misconception about the transported data. For example, upon examination of the data set, you might learn that an entire library of data sets was mistakenly transported instead of only the intended data set.
Use the CONTENTS procedure or the PRINT procedure to list the contents of members of type DATA.
In this example, PROC CONTENTS shows the contents of a single data set in a library:
Using PROC CONTENTS to Show the Contents of a Data Set proc contents data=xptds._all_; CONTENTS PROCEDURE Data Set Name: XPTDS.GRADES Observations: . Member Type: DATA Variables: 4 Engine: XPORT Indexes: 0 Created: . Observation Length: 32 Last Modified: . Deleted Observations: 0 Protection: Compressed: NO Data Set Type: Sorted: NO Label: -----Alphabetic List of Variables and Attributes----- # Variable Type Len Pos ----------------------------------- 4 FINAL Num 8 24 1 STUDENT Char 8 0 2 TEST1 Num 8 8 3 TEST2 Num 8 16 DATAPROG: Creates data sets for TRANSPORTING CONTENTS PROCEDURE -----Directory----- Libref: XPTDS Engine: XPORT Physical Name: $1$DUA330:[HOSTVAX.JOE.XPTTEST]XPTDS.DAT # Name Memtype Indexes --------------------------- 1 GRADES DATA
If you detect problems, re-create the transport file and restore it again at the source computer.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.