Previous Page | Next Page

Processing a KSDS in a SAS Job

Erasing Records from a KSDS

To erase a record from a KSDS, complete the following steps:

  1. specify the VSAMUPDATE system option.

  2. Use an INFILE statement and an INPUT statement to read the record and a FILE statement and a PUT statement to erase the record. Of course, the INFILE statement and FILE statement must have the same fileref; they must reference the same data set.

  3. Specify the key that you want to erase with the KEY= option and the ERASE= option in the INFILE statement. The ERASE= option specifies a numeric SAS variable that tells SAS whether a record is to be erased.

See SAS Options for a KSDS for a list of the options that you can use to erase records. The following list explains which values you can set for the ERASE= option as well as what the values specify:

In the following example, the variable SASKEY in the SAS data set KEYS contains the keys of the records that you want to erase. Notice that the PUT statement erases the record rather than updating it, because the ERASE= variable, ERASEVAR, is set to a value of 1.

data eleven;
   set keys;
   erasevar=1;
   infile myksds vsam key=saskey erase=erasevar;
   file myksds vsam;
   input;
   if (saskey eq '547392749') then do;
      put _infile_;
   end;
run;

Previous Page | Next Page | Top of Page