Previous Page | Next Page

Processing an ESDS in a SAS Job

Adding Records after Reading

To add a new record after reading an existing record, set the RBA= variable to a different value before you execute the PUT statement. The new RBA value instructs VSAM not to update the last record retrieved with an INPUT statement; instead, it adds the data as a new record. (The actual value in the RBA= variable is ignored because VSAM chooses the RBA for a new record.)

data four;
   set rbas;
   infile myesds vsam rba=rbanum;
   file myesds vsam;
   input;
   if (rbanum= 1080) then do;
      rbanum= 803;
      lastname='Rubble    ';
      frstname='Barney    ';
      file myesds vsam ;
      put @1 _infile_
          @10 lastname
          @20 frstname;
   end;
run;

In the example, MYESDS is read until RBANUM 1080 is found; then a record is added after 1080 because changing the RBANUM cancels the update.

If you want to read an ESDS sequentially while adding new records, specify the SEQUENTIAL option and the RBA= option in the INFILE statement. (The SEQUENTIAL option specifies sequential record retrieval when the RBA= direct access option indicates direct record storage for the PUT statement.)

Previous Page | Next Page | Top of Page