Previous Page | Next Page

Optimizing Data Storage

Indexing Data

An index is an optional file that you can create to provide direct access to specific rows. The index stores values in ascending value order for a specific column or columns and includes information about the location of those values within rows in the table. In other words, an index enables you to locate a row by value. For example, if you use SAS to find a specific Social Security number (123-45-6789), SAS performs the search differently depending on whether there is an index on the row that contains the Social Security numbers:

When you create an index, you designate which columns to index. You can create two types of indexes:

For each indexed column, you can also perform these tasks:

In addition to writing SAS code to create indexes, you can create indexes on target tables by using SAS Data Integration Studio. In SAS Data Integration Studio, you use the properties window for the table to index individual columns. When you create the index, you can also specify Unique values and No missing values. Note that any indexes registered in metadata for a target table are physically created when the job is run. Simply editing the properties for an existing table and adding indexes does not update the physical table. The following figure shows the SAS Data Integration Studio properties dialog box for a table:

The Indexes Tab in the Properties Dialog Box for a Table Named STORE_ID

[The Indexes Tab in the Properties Dialog Box for a Table Named STORE_ID]

In general, SAS can use an index to improve performance in these situations:

Even though an index can reduce the time that is required to locate a set of rows, especially for a large table, there are costs that are associated with creating, storing, and maintaining the index. When deciding whether to create an index, you must consider increased resource usage, along with the performance improvement.

Once an index exists, SAS treats it as part of the table. That is, if you add or delete columns or modify values, the index is automatically updated.

For more information about creating indexes, see SAS Language Reference: Concepts.

Previous Page | Next Page | Top of Page