Previous Page | Next Page

Processing VSAM Data Sets in SAS Programs

Reading Records from a VSAM Data Set


Different Ways to Read Records

You must specify either the VSAMREAD or VSAMUPDATE system option in order to read VSAM data sets. Records can be read with sequential access, direct access, or with a combination of both by using skip sequential access. By default, Read access is sequential.

Options in the INFILE statement specify how the read operation is to be performed. Processing an ESDS in a SAS Job, Processing a KSDS in a SAS Job, and Processing an RRDS in a SAS Job describe reading data from each of the three VSAM data set types.


Sequential Access

Sequential access means that a record is retrieved by one of the following methods:

Sequential record retrieval depends on the location of the previously retrieved record.

By default, SAS processes VSAM and other data sets sequentially. When access is sequential, SAS performs a standard look-ahead read. When SAS encounters the end of the data set while processing sequentially, the END= variable, if specified, is set to 1.


Direct Access

Access is direct if one of the direct access options (KEY=, RRN=, or RBA=) is specified in the INFILE statement.

When you access a VSAM data set directly in a SAS job, the standard look-ahead read used with sequential access is inhibited. Therefore, the END= INFILE statement option (if specified) is ignored with direct access because the END= variable is never set to 1. This means there is no automatic mechanism to end a DATA step that directly accesses a VSAM data set. Instead, you must end the DATA step using one of the following statements:


Skip Sequential Access

Skip sequential access is a two-step process that combines both direct and sequential access. After the initial record is located with keyed direct access, subsequent records are retrieved sequentially. Skip sequential processing can be used with a KSDS, an RRDS, and an ESDS with an alternate index. The SKIP option in the INFILE statement indicates skip sequential access. When you are processing a VSAM data set skip sequentially, you must end the DATA step with either a STOP statement or, if you are processing a SAS data set against the VSAM data set, with a SET statement.

Previous Page | Next Page | Top of Page