SAS Institute. The Power to Know

SAS/ACCESS(R) 9.2 for Relational Databases: Reference, Second Edition

Previous Page | Next Page

Overview of the SAS/ACCESS Interface to Relational Databases

Selecting a SAS/ACCESS Method


Methods for Accessing DBMS Tables and Views

In SAS/ACCESS, you can often complete a task in several ways. For example, you can access DBMS tables and views by using the LIBNAME statement or the Pass-Through Facility. Before processing complex or data-intensive operations, you might want to test several methods first to determine the most efficient one for your particular task.


SAS/ACCESS LIBNAME Statement Advantages

You should use the SAS/ACCESS LIBNAME statement for the fastest and most direct method of accessing your DBMS data except when you need to use SQL that is not ANSI-standard. ANSI-standard SQL is required when you use the SAS/ACCESS library engine in the SQL procedure. However, the Pass-Through Facility accepts all SQL extensions that your DBMS provides.

Here are the advantages of using the SAS/ACCESS LIBNAME statement.

  • Significantly fewer lines of SAS code are required to perform operations on your DBMS. For example, a single LIBNAME statement establishes a connection to your DBMS, lets you specify how data is processed, and lets you easily view your DBMS tables in SAS.

  • You do not need to know the SQL language of your DBMS to access and manipulate data on your DBMS. You can use such SAS procedures as PROC SQL or DATA step programming on any libref that references DBMS data. You can read, insert, update, delete, and append data. You can also create and drop DBMS tables by using SAS syntax.

  • The LIBNAME statement gives you more control over DBMS operations such as locking, spooling, and data type conversion through the use of LIBNAME and data set options.

  • The engine can optimize processing of joins and WHERE clauses by passing them directly to the DBMS, which takes advantage of the indexing and other processing capabilities of your DBMS. For more information, see Overview of Optimizing Your SQL Usage.

  • The engine can pass some functions directly to the DBMS for processing.


Pass-Through Facility Advantages

Here are the advantages of using the Pass-Through Facility.

  • You can use Pass-Through Facility statements so the DBMS can optimize queries, particularly when you join tables. The DBMS optimizer can take advantage of indexes on DBMS columns to process a query more quickly and efficiently.

  • Pass-Through Facility statements let the DBMS optimize queries when queries have summary functions (such as AVG and COUNT), GROUP BY clauses, or columns that expressions create (such as the COMPUTED function). The DBMS optimizer can use indexes on DBMS columns to process queries more rapidly.

  • On some DBMSs, you can use Pass-Through Facility statements with SAS/AF applications to handle transaction processing of DBMS data. Using a SAS/AF application gives you complete control of COMMIT and ROLLBACK transactions. Pass-Through Facility statements give you better access to DBMS return codes.

  • The Pass-Through Facility accepts all extensions to ANSI SQL that your DBMS provides.


SAS/ACCESS Features for Common Tasks

Here is a list of tasks and the features that you can use to accomplish them.

SAS/ACCESS Features for Common Tasks
Task SAS/ACCESS Features
Read DBMS tables or views LIBNAME statement*
Pass-Through Facility
View descriptors**
Create DBMS objects, such as tables LIBNAME statement*
DBLOAD procedure
Pass-Through Facility EXECUTE statement
Update, delete, or insert rows into DBMS tables



LIBNAME statement*
View descriptors**
Pass-Through Facility EXECUTE statement
Append data to DBMS tables DBLOAD procedure with APPEND option
LIBNAME statement and APPEND procedure*
Pass-Through Facility EXECUTE statement
Pass-Through Facility INSERT statement
List DBMS tables LIBNAME statement and SAS Explorer window*
LIBNAME statement and DATASETS procedure*
LIBNAME statement and CONTENTS procedure*
LIBNAME statement and SQL procedure dictionary tables*
Delete DBMS tables or views LIBNAME statement and SQL procedure DROP TABLE statement*
LIBNAME statement and DATASETS procedure DELETE statement*
DBLOAD procedure with SQL DROP TABLE statement
Pass-Through Facility EXECUTE statement
* LIBNAME statement refers to the SAS/ACCESS LIBNAME statement.

** View descriptors refer to view descriptors that are created in the ACCESS procedure.

Previous Page | Next Page | Top of Page