The ACCESS Procedure for PC Files

SAS/ACCESS Descriptors for PC Files

Overview

There are two types of descriptor files: access descriptors and view descriptors.

Access Descriptors

An access descriptor holds essential information about the structure of the PC file that you want to access. For example, you can access the file's format and name, its database field or column names, and its data types. Access descriptors can also contain the corresponding SAS information such as the SAS variable names and formats. Typically, you have only one access descriptor for each PC file.
An access descriptor describes only a PC file format and contents to SAS, that is, it is a master description file of the PC file for SAS. You cannot use an access descriptor in a SAS program. Instead, use an access descriptor to create other SAS files, called view descriptors, that you use in SAS programs.
When you create an access descriptor, the default setting for a SAS variable name is a blank. However, if you have previously entered or modified any of the SAS variable names, the RESET statement resets the modified names to the default names that are generated by the ACCESS procedure. How the default SAS variable names are set depends on whether you included the ASSIGN statement. If you omitted ASSIGN or set it to NO, the default names are blank. If you set ASSIGN= YES, the default names are the first eight characters of each PC file column name.
The current SAS variable format is also reset to the default SAS format, which was determined from the column's data type. Any columns that were previously dropped, but that are specified in the RESET statement, become available; they can be selected in view descriptors that are based on this access descriptor.
SAS/ACCESS descriptor files are the tools that the ACCESS procedure uses to establish a connection to a PC file. There are two types of descriptor files: access descriptors and view descriptors. Use the ACCESS procedure to create descriptors.

View Descriptors

A view descriptor defines some or all of the data that is described by one access descriptor (and, therefore, one PC file). For example, you might want to use only three of nine possible database columns and only some of the rows in a PC file. The view descriptor enables you to do this by selecting the database fields or columns that you want to use and specifying criteria to retrieve only the rows that you want. Typically, you create several view descriptors based on one access descriptor, where each view descriptor selects a different subset of the PC files data.
A view descriptor is a SAS data set or, more specifically, a SAS data view. You use a view descriptor in a SAS program much as you would any SAS data set. For example, you can specify a view descriptor in the DATA= statement of a SAS procedure or the SET statement of a DATA step. You can use a view descriptor in a SELECT statement of the SQL procedure to join view descriptor data with SAS data, for example.
You can use a view descriptor to update data directly in some of the PC file formats, such as the DBF file format.
In some cases, you might also want to create a SAS data file from data stored in a PC file. Using a view descriptor to copy PC files data into a SAS data file is called extracting the data.
When you create a view descriptor, the RESET statement clears any columns that were included in the SELECT statement.
When creating the view descriptor, if you reset a SAS variable and select it again within the same procedure execution, the SAS variable names and formats are reset to their default values. The defaults are generated from the column names and data types. This applies only if you have omitted the ASSIGN statement or set the value to NO when you created the access descriptor.
If you specified ASSIGN= YES when you created the access descriptor, the RESET = option has no effect on the view descriptor.
Use a view descriptor to update data directly in some of the PC file formats, such as the DBF file format.
Create a SAS data set from data stored in a PC file. When a view descriptor is used to copy PC files data into a SAS data set is called extracting the data.

Extracting Data Using a View

It might be more efficient to use a view descriptor to extract PC files data and place it in a SAS data file.
A PC file is read every time a view descriptor is referred to in a SAS program and is executed. It is better to extract data under these circumstances:
  • If the file is large and you use the data repeatedly in SAS programs.
  • If you use sorted data several times in a SAS program.
  • For added security, you can assign a password to the extracted SAS data file.

Tasks and Associated Statements

ACCESS Procedure Tasks
Task
Options and Statements
create an access descriptor
PROC ACCESS
DBMS= DBF | DIF | WK n | XLS;
CREATE libref.member-name;
ACCESS database description-statements (required) edit (options) ;
RUN;
create an access descriptor and a view descriptor
PROC ACCESS
DBMS= DBF | DIF | WKn | XLS;
CREATE libref.member-name
CREATE libref.member-name. VIEW;
ACCESS database description-statements (required) edit (options) ;
SELECT column-list edit (options) ;
RUN;
create a view descriptor from an existing access descriptor
PROC ACCESS
DBMS= DBF | DIF | WK
n | XLS
ACCDESC= libref.access-descriptor;
CREATE libref.member-name. VIEW;
SELECT column-list edit (options) ;
RUN;
Note: You can create one or more access descriptors and view descriptors in one execution of PROC ACCESS, or you can create the descriptors in separate executions.