Previous Page | Next Page

Processing a KSDS in a SAS Job

Introduction to KSDS

Each record in a Key-Sequenced Data Set (KSDS) has a key that contains a unique value. KSDS records are retrieved by their key sequences. The key is a contiguous portion of the record and is defined when the data set is created. A KSDS is always defined with a prime index that relates the record's key value to its relative location in the data set. VSAM uses the index to locate a record for retrieval and to locate a collating position for record insertion. A KSDS is the most flexible approach for most applications because the record can be accessed directly via the key field. Access is not dependent on the physical location of the record in the data set.

You can read, add, update, and erase KSDS records in SAS programs. The options that are associated with each of these operations are described in the following sections. In many cases, the option's meaning depends on how it is used within a SAS program. (Loading KSDS records is discussed separately in Defining and Loading a VSAM Data Set.)

Here are two helpful tables and their descriptions:

There are examples of reading, adding, updating, and performing combined operations on a KSDS data set. The examples are based on the STUDENT data set described in Sample STUDENT Data Set. You can run the examples by using the sample programs provided in the Help system and following the steps to define and load a KSDS described in Defining and Loading a VSAM Data Set.

For information on using an ESDS in SAS jobs, see Processing an ESDS in a SAS Job. For information on using an RRDS, see Processing an RRDS in a SAS Job.

Previous Page | Next Page | Top of Page