Chapter Contents

Previous

Next
Moving and Accessing SAS Files across Operating Environments

Restoring a Transport File of Member Type DATA

You can use one of these methods to restore a transport file for member type DATA:


Using a Data Step to Restore a Single Data Set from a Transport File

This example uses the DATA step to restore a data set from a transport file.

libname xportin xport 'transport-file';
libname target 'SAS-data-library';
data target.grades;
   set xportin.grades;
run;

In the preceding example, the libref XPORTIN points to the location of the exported data set that was transferred to the target host. The XPORT engine specifies that the data set is to be read in transport format. The libref TARGET points to a new location where the translated file will be copied. The SET statement reads the data set XPORTIN.GRADES in transport format and translates it and copies it to the location specified in the DATA statement. Because a DATA step with the XPORT engine was used at the source host to create the transport file for a single data set, only a data set can be restored at the target host.


Using PROC COPY to Restore One or More Data Sets from a Transport File

This example uses the COPY procedure to restore one or more data sets from a transport file.

libname xportin xport 'transport-file';
libname target 'SAS-data-library';
proc copy in=xportin out=target memtype=data;
  select grades;
run;

In the preceding example, the libref XPORTIN points to the location where the transport file was transferred to the target host. The XPORT engine in this LIBNAME statement specifies that the transport file at this location is to be read in transport format. The libref TARGET points to a new location where the transport file will be copied in native format. The PROC COPY statement copies the selected data set GRADES from the library that is identified in the IN= option to the new library that is identified in the OUT= option. The MEMTYPE=DATA option limits the files that are to be copied to type DATA, which excludes catalogs and views.

Using a SELECT statement, you specify one or more specific data sets to be copied to the new library. To specify that all data sets in the transport file be copied, omit the SELECT statement from PROC COPY.

Note:   You can use the EXCLUDE statement in PROC COPY to omit explicitly the data sets that you do not want rather than the SELECT statement to specify the data sets that you want.  [cautionend]


Using PROC CIMPORT to Import One or More Data Sets from a Transport File

This example uses the CIMPORT procedure to import multiple data sets from a transport file.

filename importin 'transport-file';
libname target 'SAS-data-library';
proc cimport infile=importin library=target memtype=data;
run;

In the preceding example, the fileref IMPORTIN points to the location where the transport file was transferred to the target host. The libref TARGET points to a new location where the transport file will be copied. The PROC CIMPORT statement copies as its source the file that is identified in the INFILE= option to the location identified in the LIBRARY= option. The PROC CIMPORT statement implicitly translates the transport file into the target host native format.

Because the LIBRARY= option permits both data sets and catalogs to be copied to the library, you need to specify MEMTYPE=DATA to restrict the operation only to data sets in the library. Omitting the MEMTYPE= option permits both data sets and catalogs, in the file referenced by the fileref IMPORTIN, to be copied to the location referenced by the libref TARGET.

In order to subset the destination member in PROC CIMPORT, use either the SELECT statement, the EXCLUDE statement, or the MEMTYPE= option. Here is an example of subsetting:

filename importin 'transport-file';
libname target 'SAS-data-library';
proc cimport infile=importin library=target memtype=data;
  select grades;
run;

In the preceding example, the libref TARGET and the MEMTYPE= option points to the new location where the transport file will be copied. The fileref IMPORTIN points to the location where the transport file was transferred to the target host. The PROC CIMPORT statement copies as its source the file that is identified in the INFILE= option to the location identified in the LIBRARY= option. The PROC CIMPORT statement implicitly translates the transport file into the target host native format.

The SELECT statement selects only the data set GRADES for the library TARGET.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.