|
Migrating SAS Files to SAS 9
|
|
Since SAS 8 and earlier files were written with 32-bit storage, and SAS
9 files on UNIX use 64-bit storage, most SAS files saved on UNIX using
SAS 8 and earlier versions probably should be migrated to SAS 9 files.
SAS 9 can read SAS data sets that were written by older versions of
SAS. So, if you need only read from a SAS data set, you may not need to
copy/move it to a SAS 9 data set. On the other hand, SAS catalogs, such
as a format catalog, must be migrated to SAS 9 before SAS 9 can read
them.
This document contains four sections
- Using proc
migrate
for SAS data sets only. When
you have only SAS data sets (no format catalog, for example) to
migrate, the migrate
procedure is the easiest method.
Proc migrate
preserves the entire history of a SAS
data set but will not migrate SAS catalogs without software not
available on the central UD UNIX machines. (Migrating other types
of SAS files such as views, MDDBs, compiled data-step programs,
also require special considerations.)
- Using proc
cport
and proc cimport
to
export and then import SAS catalogs and proc migrate
to migrate SAS data sets. This approach is a little cumbersome, because
the migration must be separated into two parts -- migrating catalogs
and migrating data sets. But using proc migrate
for
the SAS data sets preserves the history of the data sets.
- Using proc
cport
to export all SAS files and proc
cimport
to import all SAS files. This approach is
conceptually a little simplier than the second approach, but it does
not preserve the history of the SAS data sets.
- Validation
For the examples below, there are two directories, one for the old SAS
files and one for the SAS 9 files, called sas8 and sas9, respectively.
These two directories are located at the same level in the directory
structure
<1>% ls -l
total 16
drwx------ 3 larryh 1864 4096 Sep 27 11:56 sas8
drwx------ 2 larryh 1864 4096 Sep 27 11:57 sas9
The examples contain two SAS data sets ds1
and ds2
and one format catalog, formats
. The sas8
directory contains all three
<2>% ls -l sas8/*.sas7*
-rw------- 1 larryh 1864 16384 Sep 27 11:43 sas8/ds1.sas7bdat
-rw------- 1 larryh 1864 16384 Sep 27 11:43 sas8/ds2.sas7bdat
-rw------- 1 larryh 1864 24576 Sep 27 11:56 sas8/formats.sas7bcat
But the format catalog is present in the sas8 directory only for the two
examples using the catalog.
This document provides a short summary of migration procedures. More
details are available in a document
prepared by SAS Institute.
Proc migrate
, No Catalogs
If you have only sas data sets, migration to SAS 9 is very easy. Use
proc migrate. All the data sets in a SAS library are migrated at once,
and the entire history of each data set is copied. No options need be
considered.
For a simple example, place the following commands
libname sas8 '../sas8';
libname sas9 '.';
proc migrate in=sas8 out=sas9; run;
in a file called "migrate.sas
" in the sas9 directory.
(Note: The period enclosed in single quotes in the second
libname
statement stands for the current working directory,
which is sas9.)
The two libname statements identify the old and new libraries. These
two libname statements must not identify the same UNIX
directory, i.e, they must be two distinct SAS libraries.
Also, the new library, sas9
in this example, should not contain
any SAS data sets before the migration.
To execute the migration, be sure sas9 is the current working directory and
type
sas migrate
at the UNIX prompt.
After completing the migration, the SAS data sets in these two directories
have identical file names
<3>% ls -l sas8/*.sas7b*
-rw------- 1 larryh 1864 16384 Sep 27 11:43 sas8/ds1.sas7bdat
-rw------- 1 larryh 1864 16384 Sep 27 11:43 sas8/ds2.sas7bdat
<4>% ls -l sas9/*.sas7b*
-rw------- 1 larryh 1864 16384 Sep 27 11:57 sas9/ds1.sas7bdat
-rw------- 1 larryh 1864 16384 Sep 27 11:57 sas9/ds2.sas7bdat
Proc migrate
, Catalog(s) Present
Proc migrate cannot migrate SAS catalogs without specialized software
not currently available on the central UNIX computers (SAS
SHARE/CONNECT). You can use proc migrate to migrate SAS data sets and
combine proc cport
with proc cimport
to
migrate the catalogs. For an example, place the following
commands
libname library '.';
proc cport
lib=library file="formats8.port" memtype=catalog; run;
in a file named "exportfmts.sas
" in the sas8 directory.
These commands must be run using SAS 8; use the sas8.2 UNIX command to
execute them in batch mode. Type
sas8.2 exportfmts
at the UNIX prompt. The output of this job is the portable SAS data
set named "formats8.port
", located in the sas8
directory.
This portable file must be imported to a SAS 9 format catalog. To do the
import, place the following commands
libname sas9 '.';
proc cimport infile="../sas8/formats8.port" memtype=cat lib=sas9; run;
in a file named "importcat.sas
" in the sas9 directory.
Make the sas9
directory the current working directory,
and use the sas command
sas importcat
to execute them in batch mode. The job imports the catalog and
produces a SAS 9 version of it.
After importing the catalog, proc migrate may be used to import the SAS
data sets. Use the same procedures as in the previous
section. SAS produces error messages because proc migrate cannot
migrate the format catalog, but it successfully migrates the data sets and
associates the formats with the variables to which they are assigned.
After completing the migration in this example, both the
sas8
and sas9
directories contain two SAS
data sets and one SAS catalog
<5>% ls -l sas8/*.sas7*
-rw------- 1 larryh 1864 16384 Sep 27 11:43 sas8/ds1.sas7bdat
-rw------- 1 larryh 1864 16384 Sep 27 11:43 sas8/ds2.sas7bdat
-rw------- 1 larryh 1864 24576 Sep 27 11:56 sas8/formats.sas7bcat
<6>% ls -l sas9/*.sas7*
-rw------- 1 larryh 1864 16384 Sep 27 11:57 sas9/ds1.sas7bdat
-rw------- 1 larryh 1864 16384 Sep 27 11:57 sas9/ds2.sas7bdat
-rw------- 1 larryh 1864 24576 Sep 27 11:45 sas9/formats.sas7bcat
Proc cport
and cimport
Proc cport
can be used to create a portable SAS file containing
all the SAS data sets and catalogs in the sas8 directory. And proc
cimport
can be used to import them into the SAS 9 files in the sas9
directory. The procedure is straightforward, but unlike proc migrate,
proc cport
and cimport
do not preserve the
entire history of the SAS data sets. Hence, if the history is
important, use proc migrate for the SAS data sets.
To create the portable file containing all SAS files -- data sets and
catalogs -- place the following commands
libname library '.';
proc cport lib=library file="allsasfiles.port" memtype=all; run;
in a file named exportall.sas
in the sas8
directory.
Execute them in batch mode using the UNIX sas8.2 command
sas8.2 exportall
The job produces a portable SAS file named allsasfiles.port
in
the sas8
directory.
To import all the files into SAS 9 format in the sas9 directory, place the
following commands in a file called "importall.sas
" in the
sas9 directory
libname sas8 '../sas8';
libname sas9 '.';
proc cimport
infile="../sas8/allsasfiles.port"
memtype=all lib=sas9; run;
and run a batch job with the command
sas importall
The same list of SAS files now appear in the sa8 and sas9 directories
as in the previous example.
Validation
Validation that the migration occurred correctly potentially involves a
number of complex issues. See the SAS
documentation mentioned above for a
thorough review and to learn how to download a set of macros for
validation of complex SAS libraries.
SAS proc compare
can be used to check that SAS data sets in the
new SAS 9 library match the source SAS data sets. Syntax for comparing
ds1
and ds2
in their SAS version 8 renditions
to their respective version 9 renditions is
libname sas8 '../sas8';
libname sas9 '.';
proc compare base=sas8.ds1 compare=sas9.ds1; run;
proc compare base=sas8.ds2 compare=sas9.ds2; run;
Partial output from this program is shown below.
The COMPARE Procedure
Comparison of SAS8.DS1 with SAS9.DS1
(Method=EXACT)
Data Set Summary
Dataset Created Modified NVar NObs
SAS8.DS1 27SEP04:11:43:20 27SEP04:11:43:20 2 10
SAS9.DS1 27SEP04:11:43:20 27SEP04:11:43:20 2 10
Variables Summary
Number of Variables in Common: 2.
Observation Summary
Observation Base Compare
First Obs 1 1
Last Obs 10 10
Number of Observations in Common: 10.
Total Number of Observations Read from SAS8.DS1: 10.
Total Number of Observations Read from SAS9.DS1: 10.
Number of Observations with Some Compared Variables Unequal: 0.
Number of Observations with All Compared Variables Equal: 10.
NOTE: No unequal values were found. All values compared are exactly
equal.
^L The SAS System 2
15:14 Friday, October 1, 2004
The COMPARE Procedure
Comparison of SAS8.DS2 with SAS9.DS2
(Method=EXACT)
Data Set Summary
Dataset Created Modified NVar NObs
SAS8.DS2 27SEP04:11:43:20 27SEP04:11:43:20 2 15
SAS9.DS2 27SEP04:11:43:20 27SEP04:11:43:20 2 15
Variables Summary
Number of Variables in Common: 2.
Observation Summary
Observation Base Compare
First Obs 1 1
Last Obs 15 15
Number of Observations in Common: 15.
Total Number of Observations Read from SAS8.DS2: 15.
Total Number of Observations Read from SAS9.DS2: 15.
Number of Observations with Some Compared Variables Unequal: 0.
Number of Observations with All Compared Variables Equal: 15.
NOTE: No unequal values were found. All values compared are exactly
equal.
Notice that both data sets compare exactly.
Last modified: September 27, 2004
This page maintained by Larry Hotchkiss.
Copyright © University of Delaware, 2004.