13.07.2015 Views

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SAS/ACCESS 9.2 for Relational Databases: Reference, Fourth Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

304 DBINDEX= Data Set Option 4 Chapter 11Queries must be issued to the necessary DBMS control or system tables to extractindex in<strong>for</strong>mation about a specific table or validate the index that you specified.You can enter the DBINDEX= option as a LIBNAME option, <strong>SAS</strong> data set option, oran option with PROC SQL. Here is the order in which the engine processes it:1 DATA step or PROC SQL specification.2 LIBNAME statement specificationSpecifying the DBKEY= data set option takes precedence over DBINDEX=.ExamplesHere is the <strong>SAS</strong> data set that is used in these examples:data s1;a=1; y=’aaaaa’; output;a=2; y=’bbbbb’; output;a=5; y=’ccccc’; output;run;This example demonstrates the use of DBINDEX= in the LIBNAME statement:libname mydblib oracle user=myuser password=userpwd dbindex=yes;proc sql;select * from s1 aa, x.dbtab bb where aa.a=bb.a;select * from s1 aa, mydblib.dbtab bb where aa.a=bb.a;The DBINDEX= values <strong>for</strong> table dbtab are retrieved from the DBMS and comparedwith the join values. In this case, a match was found so the join is passed down to theDBMS using the index. If the index a was not found, the join would take place in <strong>SAS</strong>.The next example demonstrates the use of DBINDEX= in the <strong>SAS</strong> DATA step:data a;set s1;set x.dbtab(dbindex=yes) key=a;set mydblib.dbtab(dbindex=yes) key=a;run;The key is validated against the list from the DBMS. If a is an index, then a pass-downoccurs. Otherwise, the join takes place in <strong>SAS</strong>.This example shows how to use DBINDEX= in PROC SQL:proc sql;select * from s1 aa, x.dbtab(dbindex=yes) bb where aa.a=bb.a;select * from s1 aa, mylib.dbtab(dbindex=yes) bb where aa.a=bb.a;/*or*/select * from s1 aa, x.dbtab(dbindex=a) bb where aa.a=bb.a;select * from s1 aa, mylib.dbtab(dbindex=a) bb where aa.a=bb.a;See AlsoTo assign this option to a group of relational DBMS tables or views, see the“DBINDEX= LIBNAME Option” on page 125.“DBKEY= Data Set Option” on page 305“MULTI_DATASRC_OPT= LIBNAME Option” on page 160

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!