Using the SAS/ACCESS Interface to CA-IDMS |
The preceding introductory DATA step example can be made into a DATA step view. A DATA step view is a SAS data set of type VIEW that contains a definition of the data rather than containing the physical data. For CA-IDMS, a DATA step view is a compiled version of statements that, when executed, access and retrieve the data from CA-IDMS.
A DATA step view is a stored SAS file that you can reference in other SAS tasks to access data directly. A view's input data can come from one or more sources, including external files and other SAS data sets. Because a DATA step view only reads (opens for input) other files, you cannot update the view's underlying data. For a complete description of using DATA step views, refer to SAS Language Reference: Dictionary.
Note: You cannot name a fileref for a task that has the same name as the CA-IDMS subschema.
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.
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;
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.