Advanced:
More Possibilites on Reading Data into SAS
Reading older
SAS data sets: SAS Engines
What are
Engines?
SAS data sets are stored in a special format.
Only software that can recognize the special format
can read SAS data files. There are two principal
types of SAS data sets for PC's. The first type is
created by SAS for DOS using SAS version 6.03 or
6.04 and is characterized by files that have the
suffix *.ssd.
The second type is created by SAS for Windows using
Windows-SAS Version 6.08 (or later) and is
characterized by files that have the suffix
*.sd2. The
manner in which data are stored differs between the
two types. As a result, the type of SAS data set
has to be specified when reading a SAS data
set.
The manner in which SAS data sets are stored in
Windows-SAS differs from that in SAS for DOS. The
data sets saved using the SAS version 6.08 format
or higher have additional features that were not
included in the DOS-SAS data sets. The additional
features are designed to speed processing, and
include
- "index" variables
- the ability to create "views"
We will not discuss these features here. DOS-SAS
can not create data sets that have the Windows-SAS
features. However, Windows-SAS can create DOS-SAS
data sets. When reading a SAS data set, the SAS
system needs to identify the type of SAS data set.
It does so by identifying with the data set a SAS
version, called an
"engine".
There is an "engine" for each version of SAS.
However, since the DOS versions 6.03 and 6.04 of
SAS create identical data sets, and the Windows
versions (6.08 or later) create nearly identical
data sets, we can distinguish between two principal
engines. The Engines are:
- V603/V604
- Equiv. to DOS-SAS 6.03 or SAS 6.04, with
data stored as *.ssd
- V608/V610/V612
- Equivalent to Windows-SAS 6.08/6.10 and
stored as *.sd2
While the version of SAS used to create a SAS
data set is needed to read in a SAS data file, SAS
data files using earlier SAS versions can be
created using newer SAS engines.
Identifying Engines in
SAS
SAS data files with the suffix *.ssd or *.sd2 do
not uniquely identify the engine that created the
data file, but are sufficient for SAS to read the
data set. Engines are identified by specifying the
"engine" option in a LIBNAME statements. For
example,
LIBNAME old4 V604 c:\temp\old';
will associate with the LIBREF "old4" the engine
"V604". Thus, files saved in C:\TEMP\OLD with SAS
versions 6.03 or 6.04 can be accessed using the
LIBREF "old4".
More than one LIBREF can be assigned to the same
path if SAS data sets that have been created with
different engines are stored in the same location.
For example, we may have an additional LIBREF
defined for SAS 6.10 data sets given by :
LIBNAME old10 V610
c:\temp\old';
The LIBREF "old10" would be used to identify SAS
data sets that were stored using SAS 6.10.
Note that the "engine" is an option in a LIBNAME
statement, and not essential. When no "engine" is
specified, SAS 6.10 will determine the "engine" it
considers best to use. The engine is identified as
follows:
- a. if there are no SAS data files in
the LIBREF, then the engine is the current SAS
version executing, V612 (or later).
- b. if SAS data files exist in the LIBREF
that were created by the same engine, then that
engine is assigned the LIBREF.
- c. if SAS data files exist in the LIBREF
that were created using different engines, then
the most recent SAS engine will be used (ie.
V612).
Once an "engine" is associated with a LIBREF in
a LIBNAME statement, all files read from or written
to the LIBNAME location are read or written using
the "engine" assigned to the LIBNAME.
Examples
( see Lecture
12)
|