input variable optional-specifications;input @1 soc_sec_number $char11.
@12 customer_name $char40.
@52 addr_line_1 $char30.
@82 addr_line_2 $char30.
@112 city $char28.
@140 state $char2.
@142 country $char20.
@162 zip_code $char10.
@172 home_phone $char12.
@184 office_phone $char12.;When this DL/I
INPUT statement executes, DL/I retrieves a CUSTOMER segment and places
it in the input buffer. Data for the variables specified in the DL/I
INPUT statement is then moved from the input buffer to SAS variables
in the program data vector by SAS.input@. The INPUT
statement with a trailing @ sign is described below.
input;
input@, this clears the hold.
input @;
input soc_sec_number $char11. @;
data custchck;
retain ssa1 'CUSTOMER*D '
ssa2 'CHCKACCT ';
infile acctsam dli ssa=(ssa1,ssa2) status=st
pcbno=3;
input @1 soc_sec_number $char11.
@12 customer_name $char40.
@52 addr_line_1 $char30.
@82 addr_line_2 $char30.
@112 city $char28.
@140 state $char2.
@142 country $char20.
@162 zip_code $char10.
@172 home_phone $char12.
@184 office_phone $char12.
@226 check_account_number $char12.
@238 check_amount pd5.2
@243 check_date mmddyy6.
@251 check_balance pd5.2;
if st ¬= ' ' then
do;
file log;
put _all_;
abort;
end;
run;
proc print data=custchck;
title2 'Customer Checking Accounts';
run;status = ' ',
the qualified GN call is issued, the concatenated CUSTOMER and CHCKACCT
segments are placed in the input buffer, and data from both segments
are moved to SAS variables in the program data vector.
The SAS System
Customer Checking Accounts
soc_sec_ addr_
OBS number customer_name line_1 addr_line_2 city state
1 667-73-8275 WALLS, HOOPER J. 4525 CLARENDONRD RAPIDAN VA
2 667-73-8275 WALLS, HOOPER J. 4525 CLARENDONRD RAPIDAN VA
3 434-62-1234 SUMMERS, MARY T. 4322 LEON ST. GORDONSVILLE VA
4 436-42-6394 BOOKER, APRIL M. 9712WALLINGFORD PL. GORDONSVILLE VA
5 434-62-1224 SMITH, JAMES MARTIN 133 TOWNSENDST. GORDONSVILLE VA
6 434-62-1224 SMITH, JAMES MARTIN 133 TOWNSENDST. GORDONSVILLE VA
7 178-42-6534 PATTILLO, RODRIGUES 9712 COOK RD. ORANGE VA
8 156-45-5672 O'CONNOR, JOSEPH 235 MAIN ST. ORANGE VA
9 657-34-3245 BARNHARDT, PAMELA S. RT 2 BOX 324 CHARLOTTESVILLE VA
10 667-82-8275 COHEN, ABRAHAM 2345 DUKE ST. CHARLOTTESVILLE VA
11 456-45-3462 LITTLE, NANCY M. 4543 ELGINAVE. RICHMOND VA
12 234-74-4612 WIKOWSKI, JONATHAN S. 4356 CAMPUDRIVE RICHMOND VA
check_
account_ check_ check_ check_
OBS country zip_code home_phone office_phone number amount date balance
1 USA 22215-5600 803-657-3098 803-645-4418 345620145345 1702.19 12857 1266.34
2 USA 22215-5600 803-657-3098 803-645-4418 345620154633 1303.41 12870 1298.04
3 USA 26001-0670 803-657-1687 345620104732 826.05 12869 825.45
4 USA 26001-0670 803-657-1346 345620135872 220.11 12868 234.89
5 USA 26001-0670 803-657-3437 345620134564 2392.93 12858 2645.34
6 USA 26001-0670 803-657-3437 345620134663 0.00 12866 143.78
7 USA 26042-1650 803-657-1346 803-657-1345 745920057114 1404.90 12944 1502.78
8 USA 26042-1650 803-657-5656 803-623-4257 345620123456 353.65 12869 463.23
9 USA 25804-0997 803-345-4346 803-355-2543 345620131455 1243.25 12871 1243.25
10 USA 25804-0997 803-657-7435 803-645-4234 382957492811 7462.51 12876 7302.06
11 USA 26502-3317 803-657-3566 345620134522 608.24 12867 831.65
12 USA 26502-5317 803-467-4587 803-654-7238 345620113263 672.32 12870 13.28CC, GA,
or GK. SAS sets _ERROR_ to 1 if any other DL/I status code is returned or if the special
SAS status code SE is
returned. (The SE code is generated when SAS cannot format a proper DL/I call from the options specified.) If _ERROR_ is set to 1, the contents of the input buffer
and the program data vector are printed on the SAS log when another INPUT statement
is executed or when control returns to the beginning of the DATA step, whichever comes
first.
input @;
GB (end-of-file) status code is not treated as an error by the program. Therefore, the
program resets _ERROR_
to 0.
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:
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
input;