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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>SAS</strong>/<strong>ACCESS</strong> Interface <strong>for</strong> In<strong>for</strong>mix 4 Using Fully Qualified Table Names 589If you set DBDATASRC, you can issue a PROC SQL SELECT or EXECUTEstatement without first connecting to In<strong>for</strong>mix with the CONNECT statement.If you omit the CONNECT statement, an implicit connection is per<strong>for</strong>med when theSELECT or EXECUTE statement is passed to In<strong>for</strong>mix.If you create an SQL view without an explicit CONNECT statement, the view candynamically connect to different databases, depending on the value of the DBDATASRCenvironment variable.Using Fully Qualified Table NamesIn<strong>for</strong>mix supports a connection to only one database. If you have data that spansmultiple databases, you must use fully qualified table names to work within theIn<strong>for</strong>mix single-connection constraints.In this example, the tables Tab1 and Tab2 reside in different databases, MyDB1 andMyDB2, respectively.proc sql;connect to in<strong>for</strong>mix(server=testdsn);create view tab1v asselect * from connectionto in<strong>for</strong>mix(select * from mydb1.tab1);create view tab2v asselect * from connectionto in<strong>for</strong>mix(select * from mydb2.tab2);quit;data getboth;merge tab1v tab2v;by common;run;Because the tables reside in separate databases, you cannot connect to each databasewith a PROC SQL CONNECT statement and then retrieve the data in a single step.Using the fully qualified table name (that is, database.table) enables you to use anyIn<strong>for</strong>mix database in the CONNECT statement and access In<strong>for</strong>mix tables in the sameor different databases in a single <strong>SAS</strong> procedure or DATA step.

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

Saved successfully!

Ooh no, something went wrong!