1 data work.custlist; 2 infile acctsam dli status=st pcbno=2; 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.; 4 if st ¬= ' ' then do; file log; put _all_; abort; end; run; 5 proc sort data=work.custlist; by customer_name; 6 options linesize=132; proc print data=work.custlist; var home_phone office_phone; id customer_name; title2 'Customer Phone List'; 7 proc print data=work.custlist; var addr_line_1 addr_line_2 city state country zip_code; id customer_name; title2 'Customer Address List'; run;
1 | The DATA statement references a temporary SAS data set called CustList, which is to be opened for output. |
2 | The INFILE statement tells SAS to use a PSB called ACCTSAM. The DLI option tells SAS that ACCTSAM is a DL/I PSB instead of a fileref. The statement also tells the IMS interface to use the second PCB and to return the DL/I STATUS code in the ST variable. |
3 | The INPUT statement causes a GN (get-next) call to be issued. The PCB being used is
sensitive only to the CUSTOMER segment, so the get-next calls retrieve only CUSTOMER
segments. When the INPUT statement
executes, data is retrieved from a CUSTOMER segment and placed in the input buffer.
The data is then moved to the specified SAS variables in the program data vector (SOC_SEC_NUMBER,
CUSTOMER_NAME, and so on).
As the DATA step executes, CUSTOMER segments are retrieved from AcctDBD, and SAS observations
that
contain the CUSTOMER data are written to the CustList data set. Because program access
is sequential, the DATA step stops executing when the DL/I STATUS code indicates an
end-of-file condition.
|
4 | The status code is checked for non-blank values. For any non-blank status code except
GB , all values from the program data vector are written to the SAS log, and the DATA
step is canceled. If the status code variable value is GB , the DATA step terminates with an end-of-file condition if the processing was sequential
(using non-qualified SSAs). Since this example uses no SSA, the database is processed sequentially and no check for a status code of GB is required.
|
5 | The SORT procedure sorts the CustList data set alphabetically by customer name. |
6 | The PRINT procedure first prints a Customer Phone List. |
7 | The procedure is invoked again to print a Customer Address List. |
12 data work.custlist; 13 infile acctsam dli status=st pcbno=2; 14 input @1 soc_sec_number $char11. 15 @12 customer_name $char40. 16 @52 addr_line_1 $char30. 17 @82 addr_line_2 $char30. 18 @112 city $char28. 19 @140 state $char2. 20 @142 country $char20. 21 @162 zip_code $char10. 22 @172 home_phone $char12. 23 @184 office_phone $char12.; 24 if st ^= ' ' then 25 do; 26 file log; 27 put _all_; 28 abort; 29 end; 30 NOTE: The infile ACCTSAM is: (system-specific pathname), (system-specific file attributes) NOTE: GB -End of database encountered NOTE: 10 records were read from the infile (system-specific pathname). The minimum record length was 225. The maximum record length was 225. NOTE: The data set WORK.CUSTLIST has 10 observations and 10 variables. 31 proc sort data=work.custlist; 32 by customer_name; 33 34 options linesize=132; NOTE: The data set WORK.CUSTLIST has 10 observations and 10 variables. 35 proc print data=work.custlist; 36 var home_phone office_phone; 37 id customer_name; 38 title2 'Customer Phone List'; 39 NOTE: The PROCEDURE PRINT printed page 1. 40 proc print data=work.custlist; 41 var addr_line_1 addr_line_2 city state country zip_code; 42 id customer_name; 43 title2 'Customer Address List'; 44 run; NOTE: The PROCEDURE PRINT printed page 2.
Customer Phone List customer_name home_phone office_phone BARNHARDT, PAMELA S. 803-345-4346 803-355-2543 BOOKER, APRIL M. 803-657-1346 COHEN, ABRAHAM 803-657-7435 803-645-4234 LITTLE, NANCY M. 803-657-3566 O'CONNOR, JOSEPH 803-657-5656 803-623-4257 PATTILLO, RODRIGUES 803-657-1346 803-657-1345 SMITH, JAMES MARTIN 803-657-3437 SUMMERS, MARY T. 803-657-1687 WALLS, HOOPER J. 803-657-3098 803-645-4418 WIKOWSKI, JONATHAN S. 803-467-4587 803-654-7238
Customer Address List addr_ customer_name line_1 addr_line_2 city state country zip_code BARNHARDT, PAMELA S. RT 2 BOX 324 CHARLOTTESVILLE VA USA 25804-0997 BOOKER, APRIL M. 9712 WALLINGFORD PL. GORDONSVILLE VA USA 26001-0670 COHEN, ABRAHAM 2345 DUKE ST. CHARLOTTESVILLE VA USA 25804-0997 LITTLE, NANCY M. 4543 ELGIN AVE. RICHMOND VA USA 26502-3317 O'CONNOR, JOSEPH 235 MAIN ST. ORANGE VA USA 26042-1650 PATTILLO, RODRIGUES 9712 COOK RD. ORANGE VA USA 26042-1650 SMITH, JAMES MARTIN 133 TOWNSEND ST. GORDONSVILLE VA USA 26001-0670 SUMMERS, MARY T. 4322 LEON ST. GORDONSVILLE VA USA 26001-0670 WALLS, HOOPER J. 4525 CLARENDON RD RAPIDAN VA USA 22215-5600 WIKOWSKI, JONATHAN S. 4356 CAMPUS DRIVE RICHMOND VA USA 26502-5317