![]() Chapter Contents |
![]() Previous |
![]() Next |
| SAS/ACCESS Interface to CA-IDMS: Reference |
The following DATA step code is part of a SAS macro that is invoked twice to create two DATA step views. When the DATA step views are referenced in the SET statements of the subsequent DATA step executions, DEPARTMENT records are read from the CA-IDMS database and selected record data values are placed in two SAS data sets. Then, each SAS data set is processed with PROC PRINT to produce the same output as shown in Department List.
The numbers in the program correspond to the numbered comments following the program.
[1] %macro deptview(viewname=,p1=,p2=,p3=);
[2] data &viewname / view &viewname;
[3] keep &p1 &p2 &p3;
retain iseq;
infile empss01 idms func=func1 record=recname
area=iarea sequence=iseq errstat=err
set=iset;
/* BIND the DEPARTMENT record */
if _n_ eq 1 then do;
func1 = 'BIND';
recname = 'DEPARTMENT';
input;
iseq = 'FIRST';
end;
/* Now get the DEPARTMENT records */
func1 = 'OBTAIN';
recname = 'DEPARTMENT';
iarea = 'ORG-DEMO-REGION';
input @;
if (err ne '0000' and err ne '0307') then go to
staterr;
if err eq '0307' then do;
_error_ = 0;
/* No more DEPT records so STOP */
stop;
end;
input
@1 department_id 4.0
@5 department_name $char45.
@50 department_head 4.0;
iseq = 'NEXT';
return;
staterr:
put @1 'WARNING: ' @10 func1 @17
'RETURNED ERR = '@37 err;
stop;
[4] %mend;
[5] %deptview(viewname=work.deptname , p1=DEPARTMENT_ID,
p2=DEPARTMENT_NAME);
[6] %deptview(viewname=work.depthead , p1=DEPARTMENT_ID,
p2=DEPARTMENT_HEAD);
options linesize=132;
[7] data work.deptlist;
set work.deptname;
[8] proc print data=work.deptlist;
title2 'DEPARTMENT NAME LIST';
[9] data work.headlist;
set work.depthead;
[10] proc print data=work.headlist;
title2 'HEADS OF DEPARTMENTS LIST';
run;
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.