Processing VSAM Data Sets in SAS Programs |
You might want to perform more than one operation in one DATA step. (For example, perhaps you want to read some records, update other records, and add new records all in one DATA step.) Regardless of the number of different operations, only one pair of INFILE and FILE statements for the data set is needed during the DATA step. Specify all the options you might need for processing the data set in its INFILE statement.
In a DATA step that combines operations, SAS determines whether you want to update existing records or add new records.
When you do not have an INPUT statement that is associated with the INFILE statement (because you are adding records without reading from the data set), SAS assumes that the data in the PUT statement is to be added as a new record. If you are processing a KSDS, you must specify a new primary key in the PUT statement. If you are processing an RRDS, you must specify an empty relative-record slot with the RRN= option in the INFILE statement.
When you do have an INPUT statement that is associated with the INFILE statement (that is, you are reading from the data set before writing), SAS assumes that the data in the PUT statement is to update the record that you have just read with the INPUT statement unless you have changed one of the following:
the RBA= variable value before the PUT statement executes for an ESDS. See Combined Operations on an ESDS for more information.
the primary key with PUT @ statements for a KSDS. The primary key is also changed if you do not copy it from the INPUT buffer because the key is blank in the PUT buffer. See Combined Operations on a KSDS for more information.
the RRN= variable value before the PUT statement executes for an RRDS. See Combined Operations on an RRDS for more information.
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.