SAS programs handle VSAM data sets
the same as any external data set. The following are examples of operations
that SAS can perform on
external data sets, which are data sets that are not created by SAS:
-
The VSAM data set can be read in
a DATA step. Information from the VSAM data set can be used to create
a SAS data set if appropriate for the application.
-
The VSAM data set can be updated
in a DATA step by adding new records or by modifying or erasing existing
records.
-
A SAS data set can be created from
a VSAM data set. You can manipulate this data set with SAS DATA steps
or procedures and then use it to update the VSAM data set in a subsequent
DATA step.
-
You can use a DATA step to generate
a SAS data view of the VSAM data set.
The following figure
illustrates a typical SAS DATA step processing a VSAM data set. A
VSAM external data set is shown as input to a SAS DATA step. Only
the INFILE statement with some of the most common special SAS options
and the FILE statement are shown. Notice that both the INFILE and
FILE statements specify the VSAM option and the fileref that refers
to the VSAM data set. The RBA=, KEY=, and RRN= direct access variables
are shown as INFILE statement options that depend on whether the VSAM
data set is an ESDS, a KSDS, or an RRDS. (You do not need to specify
a direct access option to process the data set sequentially.) The
FEEDBACK= variable is specified in the INFILE statement. Remember
that you would need both an INPUT and a PUT statement to read and
update the VSAM data set.
You can perform five general types
of operations on VSAM data sets in SAS programs:
-
read records from an existing data set. All VSAM data set types can
be read both sequentially and with one or more direct access modes.
-
add new
records to an existing VSAM data set.
-
update an existing record by retrieving, modifying, and then writing it
back to the data set. Note that the record must be retrieved before
being updated.
-
erase an existing record from an RRDS or a KSDS. The record must be retrieved
before erasing it. Records cannot be erased from an ESDS.
-
When you perform these operations,
you can use certain types of access with each data set type. See the
following table for an outline of this information. Note that VSAM
provides both sequential and some form of direct access for each data
set type.
Supported VSAM Operations and Access Types