When you update an ESDS record,
you must use the PUT statement to write the complete record. There
are two common ways of writing the record with the PUT statement:
-
Build the complete record by specifying
all fields with the PUT statement. This method might be best when
many of the fields need to be updated.
-
Copy the input record to the output
buffer (with PUT _INFILE_) and overlay selected fields. This method
might be best when relatively few fields need to be updated.
The latter method is
the easiest for most applications. The following statement copies
the last record that is read into the PUT buffer and overlays the
information starting in columns 10 and 30 with the values in NEWDATA1
and NEWDATA2:
PUT @ 1 _INFILE_
@ 10 NEWDATA1
@ 30 NEWDATA2;
In most cases, when a record is retrieved for update, no user, including
you, can access that particular record or any other records in the
same control interval. Use the UPDATE= option to avoid user lockout
when only a few of the records retrieved need to be updated.
See Using the UPDATE= Option for more information.
In the following example,
the RBAs of records are captured and stored in a SAS variable called
RBAVAR from the _RBA_ automatic variable. In the next DATA step, the
records are then read without being retrieved for update until the
condition specified in the IF clause is met. When the IF condition
is true (RBANUM=1260), the record is retrieved again with update access.
data rbas;
infile myesds vsam ;
input;
rbanum=_rba_ ;
keep rbanum;
run;
data esdsupdt;
set rbas;
updtevar=0;
infile myesds vsam rba=rbanum update=updtevar;
input;
if (rbanum=1260) then do;
updtevar=1;
input;
/* Create NEWDATA */
lastname='Flintstone ';
frstname='Fred ';
file myesds vsam ;
put @1 _infile_
@10 lastname
@20 frstname;
end;
run;