This example demonstrates the use of the trailing @. This DATA step creates two SAS
data sets, Checking and Savings, from data in the CHCKACCT and SAVEACCT
segments of the AcctDBD database. The PCB that is used defines CUSTOMER, CHCKACCT,
and SAVEACCT as sensitive segments. Since
no CALL= or SSA= variables are specified, all calls are unqualified get-next calls,
and access is
sequential.
Each call is issued by a DL/I INPUT statement with a trailing @, so the retrieved
segment is placed in the buffer and held there. Two variables are checked: ST and
SEG (the
SEGMENT= variable). If a call results in an error, the job terminates. If a call
is successful, the
program checks SEG to determine the type of the retrieved segment. Because this is
a sequential access program, a GB
(end-of-file) status code is not treated as an error by the program. Therefore, the
program resets _ERROR_
to 0.
When SEG='CUSTOMER', execution returns to the beginning of the DATA step. When the
SEG value is CHCKACCT or SAVEACCT, another DL/I INPUT statement moves the data to
SAS variables in the program data vector, and the
observation is written to the appropriate SAS data set.
data checking savings;
infile acctsam dli segment=seg status=st
pcbno=3;
input @;
if st ¬= ' ' and
st ¬= 'CC' and
st ¬= 'GA' and
st ¬= 'GK' then
do;
file log;
put _all_;
abort;
end;
if seg = 'CUSTOMER' then
return;
else
do;
input @1 account_number $char12.
@13 amount pd5.2
@18 date mmddyy6.
@26 balance pd5.2;
if seg = 'CHCKACCT' then
output checking;
else
output savings;
end;
run;
proc print data=checking;
title2 'Checking Accounts';
run;
proc print data=savings;
title2 'Savings Accounts';
run;
The following output shows the results of this
example:
Results of Using the Trailing @
The SAS System
Checking Accounts
account_
OBS number amount date balance
1 345620145345 1702.19 12857 1266.34
2 345620154633 1303.41 12870 1298.04
3 345620104732 826.05 12869 825.45
4 345620135872 220.11 12868 234.89
5 345620134564 2392.93 12858 2645.34
6 345620134663 0.00 12866 143.78
7 745920057114 1404.90 12944 1502.78
8 345620123456 353.65 12869 463.23
9 345620131455 1243.25 12871 1243.25
10 382957492811 7462.51 12876 7302.06
11 345620134522 608.24 12867 831.65
12 345620113263 672.32 12870 13.28
The SAS System
Savings Accounts
account_
OBS number amount date balance
1 459923888253 784.29 12870 672.63
2 345689404732 8406.00 12869 8364.24
3 144256844728 809.45 12863 1032.23
4 345689473762 130.64 12857 261.64
5 345689498217 9421.79 12858 9374.92
6 345689462413 950.96 12857 946.23
7 345689435776 136.40 12869 284.97
8 859993641223 845.35 12860 2553.45
9 884672297126 945.25 12868 793.25
10 345689463822 929.24 12867 924.62
Note: If the DL/I call is issued
by a DL/I INPUT statement with a trailing @ and the status code sets
_ERROR_, but you do not consider the status code to be an error and
you want to issue another get call in the same execution of the DATA
step, then you must first execute a blank DL/I statement: input;
The blank DL/I INPUT statement clears the input buffer. If the buffer is not cleared
by issuing
a blank INPUT statement, the next DL/I INPUT statement assumes that the data to be
retrieved is already in the buffer and does not issue a DL/I call. See
Example 8: Using the Blank INPUT Statement for an example that includes a blank
INPUT statement.