Logical Errors

Types of Logical Errors

Logical errors result from mistakes in program logic. There are two types of logical errors that can occur when you process VSAM data sets in a SAS program:
  • SAS logical errors, which SAS detects before invoking VSAM
  • VSAM logical errors, which VSAM detects while it attempts to process a request from your SAS program

SAS Logical Errors

The SAS VSAM interface looks for logical errors before it invokes VSAM. When SAS detects an error condition, it is a SAS logical error. When SAS cannot pass a request on to VSAM because of an error in your program, the DATA step terminates, and an error message that describes the error is printed on the SAS log. The following conditions are examples of SAS logical errors:
  • You attempt to update a VSAM data set without using the same fileref for both the INFILE and FILE statements.
  • You try to erase an ESDS record by specifying the ERASE= variable on an INFILE statement that references an ESDS.
  • You try to retrieve a spanned KSDS record by RBA.
By default, the standard INFILE statement options MISSOVER and STOPOVER are in effect for VSAM data sets, and they relate to SAS logical error conditions.
  • The MISSOVER option assigns missing values to all variables in the INPUT statement that do not have values in the INPUT buffer.
    Note that the MISSOVER option enables processing to continue instead of terminating the DATA step.
  • The STOPOVER option is the default when data overflows the current record when writing to a VSAM data set. The STOPOVER option causes the following:
    • partially built records to be written to the data set
    • the DATA step to terminate immediately with an error message
For more information about these options, see Processing VSAM Data Sets in SAS Programs.

VSAM Logical Errors

Errors in your program logic that VSAM detects are called VSAM logical errors. Here are some common VSAM logical errors:
  • trying to read a record that does not exist
  • trying to update a record without reading it first
  • trying to create a new record that violates VSAM restrictions
When a VSAM logical error is encountered, the following automatic SAS variables are set:
  1. The _IORC_ variable is set to a value of 8. (_IORC_ contains the value of the VSAM input/output return code.)
  2. The _FDBK_ variable is set to the VSAM feedback code. Some of the _FDBK_ values depend on the type of operating system and the VSAM release in use. However, the most common values are the same for all operating systems. For more information about the VSAM logical error and feedback codes, refer to your IBM documentation.
VSAM sets the I/O return code and the feedback code and returns their values to the SAS VSAM interface. The interface makes these values available to your SAS program in the automatic SAS variables _IORC_ and _FDBK_.