In this example, CUSTOMER segments are updated with change-of-address information
from a SAS 6 data set called MyData.NewAddr. The SAS 6 DATA step interface works exactly
like the SAS 7 and later DATA step interfaces, except that
the SAS 7 and later DATA step interfaces support SAS variable and member names of
up to 32 characters. The interface works as long as the SAS variable names specified
in the DL/I INPUT statement match those specified in the DL/I PUT statement. Variables
in this
SAS data set are SSN (Social Security number), NEWADDR1, NEWADDR2, NEWCITY, NEWSTATE,
and NEWZIP.
After the CUSTOMER segment is retrieved, the PUT statement formatting the output buffer
is issued. The segment
is held in the output buffer until a second PUT statement is issued that executes
a REPL call to update the CUSTOMER segment.
Notice that SSA1, a
qualified SSA, is constructed by concatenating the SSA specification with the value of the SSN
variable in the SAS data set. SSA1 is set to blanks after the GHU call because an
SSA is not needed for the REPL
call. (Since the program issues get calls with qualified SSAs, access is random.)
data _null_;
set mydata.newaddr;
length ssa1 $31;
infile acctsam dli ssa=ssa1 call=func
status=st pcbno=4;
ssa1 = 'CUSTOMER(SSNUMBER =' || ssn || ')';
func = 'GHU ';
input;
if st = ' ' then
do;
func = 'REPL';
ssa1 = ' ';
file acctsam dli;
put _infile_ @;
put @52 newaddr1 $char30.
@82 newaddr2 $char30.
@112 newcity $char28.
@140 newstate $char2.
@162 newzip $char10.;
if st ¬= ' ' then
link abendit;
end;
else
if st = 'GE' then
_error_ = 0;
else
link abendit;
return;
abendit:
file log;
put _all_;
abort;
run;
Alternatively, the two DL/I PUT statements can be combined into one without the trailing
@ sign. For example:
data _null_;
set mydata.newaddr;
length ssa1 $31;
infile acctsam dli ssa=ssa1 call=func
status=st pcbno=4;
ssa1 = 'CUSTOMER(SSNUMBER ='||ssn||')';
func = 'GHU ';
input;
if st = ' ' then
do;
func = 'REPL';
ssa1 = ' ';
file acctsam dli;
put @1 _infile_
@52 newaddr1 $char30.
@82 newaddr2 $char30.
@112 newcity $char28.
@140 newstatw $char2.
@162 newzip $char10.;
if st ¬= ' ' then
link abendit;
end;
else
if st = 'GE' then
_error_ = 0;
else
link abendit;
return;
abendit:
file log;
put _all_;
abort;
run;