PUT variable optional-specifications;
put @1 ssnumber $char11.
@12 custname $char40.
@52 addr_line_1 $char30.
@82 addr_line_2 $char30.
@112 custcity $char28.
@140 custstat $char2.
@142 custland $char20.
@162 custzip $char10.
@172 h_phone $char12.
@184 o_phone $char12.;Although the syntax
of the DL/I PUT statement is identical to that of the standard PUT
statement, your use of the DL/I PUT is often different. Segment format
and suggested uses of the DL/I PUT statement are discussed in Using the DL/I PUT Statement.data _null_;
set mydata.customer;
length ssa1 $9;
infile acctsam dli call=func ssa=ssa1
status=st pcbno=4;
file acctsam dli;
func = 'ISRT';
ssa1 = 'CUSTOMER';
put @1 ssnumber $char11.
@12 custname $char40.
@52 addr_line_1 $char30.
@82 addr_line_2 $char30.
@112 custcity $char28.
@140 custstat $char2.
@142 custland $char20.
@162 custzip $char10.
@172 h_phone $char12.
@184 o_phone $char12.;
if st ¬= ' ' then
if st = 'LB' or st = 'II' then
_error_ = 0;
else
do;
file log;
put _all_;
abort;
end;
run;To update AcctDBD with new occurrences of the CUSTOMER segment type, this program issues qualified insert calls that add observations from MyData.Customer
to the database. The DL/I INFILE statement defines ACCTSAM as the PSB. Options in the INFILE statement specify the following information:
LB or II, which indicate that the segment occurrence already exists, the automatic variable _ERROR_ is reset to 0 and processing continues.
Otherwise, all values from the program data vector are written to the SAS log, and
the DATA step cancels.
put @1 ssnumber $char11.
@12 custname $char40.
@52 addr_line_1 $char30.
@82 addr_line_2 $char30.
@112 custcity $char28.
@140 custstat $char2.
@142 custland $char20.
@162 custzip $char10.
@172 h_phone $char12.
@184 o_phone $char12.;put _infile_ @;
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;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;put _infile_;
data _null_;
length ssa1 $30;
retain db 'WIRETRN ' ;
infile acctsam dli call=func dbname=db
ssa=ssa1 status=st;
func = 'GHN ';
ssa1 = 'WIRETRAN(WIREDATE =03/31/95) ';
input;
if st = ' ' then
do;
file acctsam dli;
func = 'DLET';
ssa1 = ' ';
put _infile_;
if st ¬= ' ' then
link abendit;
end;
else
if st = 'GB' then
do;
_error_ = 0;
stop;
end;
else
link abendit;
return;
abendit:
file log;
put _all_;
abort;
run; GB is required in this DATA step because
it uses a qualified SSA and random access processing. The DATA step
does not set the end-of-file condition, and the source logic must
check for it to stop the DATA step normally.