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.

867CHAPTER30Accessing DBMS Data with theSQL Pass-Through FacilityAbout the SQL Pass-Through Facility Sample Code 867Retrieving DBMS Data with a Pass-Through Query 867Combining an SQL View with a <strong>SAS</strong> Data Set 870Using a Pass-Through Query in a Subquery 871About the SQL Pass-Through Facility Sample CodeThe examples in this section demonstrate how to use the SQL pass-through facilityto access and update DBMS data. You can use the SQL pass-through facility to readand write data between <strong>SAS</strong> and a DBMS. However, it is recommended that you usethe LIBNAME statement to access your DBMS data more easily and directly.To run these examples, follow these steps:1 Modify and submit the ACCAUTO.<strong>SAS</strong> file, which creates the appropriateLIBNAME statements <strong>for</strong> each database.2 Submit the ACCDATA.sas program to create the DBMS tables and <strong>SAS</strong> data setsthat the sample code uses.3 Submit the ACCRUN.sas program to run the samples.These programs are available in the <strong>SAS</strong> Sample Library. If you need assistancelocating the Sample Library, contact your <strong>SAS</strong> support consultant. See “Descriptions ofthe Sample Data” on page 875 <strong>for</strong> in<strong>for</strong>mation about the tables that are used in thesample code.Note: Be<strong>for</strong>e you rerun an example that updates DBMS data, resubmit theACCDATA.sas program to re-create the DBMS tables. 4Retrieving DBMS Data with a Pass-Through QueryThis section describes how to retrieve DBMS data by using the statements andcomponents of the SQL pass-through facility. The following example, creates a brieflisting of the companies who have received invoices, the amount of the invoices, and thedates on which the invoices were sent. This example accesses Oracle data.First, the code specifies a PROC SQL CONNECT statement to connect to a particularOracle database that resides on a remote server. It refers to the database with the aliasMyDb. Then it lists the columns to select from the Oracle tables in the PROC SQLSELECT clause.Note: If desired, you can use a column list that follows the table alias, such as ast1(invnum,billedon,amtinus,name) to rename the columns. This is not necessary,

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

Saved successfully!

Ooh no, something went wrong!