Chapter Contents |
Previous |
Next |
SAS/ACCESS Interface to CA-IDMS Software: Reference |
The example starts by issuing a BIND on the DEPARTMENT record and the EMPLOYEE record. This CA-IDMS call is required for each record that will be retrieved, but the BIND function itself does not retrieve any data. To generate these calls, a null INPUT statement is used. The same thing is done with the FIND CALC DEPARTMENT call. Once again, this call does not retrieve any data so the null INPUT statement is used.
Each OBTAIN call is issued by a CA-IDMS INPUT statement with a trailing @, so the retrieved record is placed in the buffer and held there. The ERR variable is checked. If a call results in an error, the job terminates. If a call is successful, another CA-IDMS INPUT statement moves the data to SAS variables in the program data vector, and the observation is written to the appropriate SAS data set. Employee List shows the output of this example.
data work.dept5100(drop=filler); infile empss01 idms func=func1 record=recname sequence=iseq errstat=err ikey=ckey ikeylen=keylen keyoff=offset set=iset; /* BIND the DEPARTMENT and EMPLOYEE */ /* records; then, if successful */ /* OBTAIN FIRST DEPARTMENT WITHIN AREA */ func1 = 'BIND'; recname = 'DEPARTMENT'; input; if (err ne '0000') then go to staterr; recname = 'EMPLOYEE'; input; if (err ne '0000') then go to staterr; /* FIND DEPT record with CALC key 5100 */ func1 = 'FIND'; recname = 'DEPARTMENT'; ckey = '5100'; keylen = 4; offset = 0; input; if (err ne '0000') then go to staterr; /* Reset the options for the next call */ func1 = 'OBTAIN'; recname = 'EMPLOYEE'; ckey = ' '; keylen = 0; offset = 0; iseq = 'FIRST'; iset = 'DEPT-EMPLOYEE'; do while (err = '0000'); /* OBTAIN EMPLOYEE records and test */ /* for success */ input @; if (err ne '0307' and err ne '0000') then go to staterr; if (err eq '0307') then do; _error_ = 0; stop; end; input @1 employee_id 4.0 @5 firstname $char10. @15 lastname $char15. @30 street $char20. @50 city $char15. @65 state $char2. @67 zip $char9. @75 phone 10.0 @85 status $char2. @87 ssnumber 9.0 @96 startdate 8.0 @104 termdate 8.0 @112 birthdate 8.0; output; iseq = 'NEXT'; end; staterr: put @1 'ERROR: ' @10 func1 @17 'returned err =' @37 err ; stop; run; proc print data=work.dept5100; title1 'All the EMPLOYEES in the BRAINSTORMING Department'; run;
All the EMPLOYEES in the BRAINSTORMING Department employee_ Obs id firstname lastname street city state zip phone status ssnumber startdate termdate birthdate 1 466 ROY ANDALE 44 TRIGGER RD FRAMINGHAM MA 03461 617554110 80 302760111 578061 500000 60030 2 457 HARRY ARM 77 SUNSET STRIP NATICK MA 02178 617432092 30 502877014 777120 100000 34040 3 467 C. BREEZE 200 NIGHTINGALE ST FRAMINGHAM MA 03461 617554238 70 111155669 279060 200000 34050 4 334 CAROLYN CROW 891 SUMMER ST WESTWOOD MA 02090 617329177 60 102398011 79061 700000 44040 5 301 BURT LANCHESTER 45 PINKERTON AVE WALTHAM MA 01476 617534110 90 112904050 675020 300000 32041 6 15 RENE MAKER 10 DROVER DR BOSTON MA 02123 617452141 40 101067334 378010 200000 45052 7 341 RICHARD MUNYON 17 BLACKHILL DR WESTWOOD MA 02090 617329001 70 111100208 180111 400000 50121 8 458 RICHARD WAGNER 677 GERMANY LN NATICK MA 02178 617432110 90 101177666 378060 700000 34030 |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.