INDEX= Data Set Option

Defines an index for a new output SAS data set.

Valid in: DATA step and PROC steps
Category: Data Set Control
Restriction: Use with output data sets only.

Syntax

Syntax Description

index-specification

names and describes a simple or a composite index to be built.

index= (variable(s) </UNIQUE> </NOMISS> )

index

is the name of a variable that forms the index or the name that you choose for a composite index.

variable(s)

is a list of variables to use in building a composite index.

UNIQUE

specifies that the values of the key variables must be unique. If you specify UNIQUE for a new data set and multiple observations have the same values for the index variables, the index is not built. A slash (/) must precede the UNIQUE option.

NOMISS

excludes all observations with missing values from the index. Observations with missing values are still read from the data set, but not through the index. A slash (/) must precede the NOMISS option.

Examples

Example 1: Defining a Simple Index

This INDEX= data set option defines a simple index for the SSN variable:
data new(index=(ssn));  

Example 2: Defining a Composite Index

This INDEX= data set option defines a composite index named CITYST that uses the CITY and STATE variables:
data new(index=(cityst=(city state)));  

Example 3: Defining a Simple and a Composite Index

This INDEX= data set option defines a simple index for SSN and a composite index for CITY and STATE:
data new(index=(ssn cityst=(city state))); 

Example 4: Defining a Simple Index with the UNIQUE Option

This INDEX= data set option defines a simple index for the SSN variable with unique values:
data new(index=(ssn /unique));  

Example 5: Defining a Simple Index with the NOMISS Option

This INDEX= data set option defines a simple index for the SSN variable, excluding all observations with missing values from the index:
data new(index=(ssn /nomiss));  

Example 6: Defining Multiple Indexes By Using the UNIQUE and NOMISS Options

This INDEX= data set option defines a simple index for the SSN variable and a composite index for CITY and STATE. Each variable must have a UNIQUE and NOMISS option:
data new(index=(ssn /unique/nomiss cityst=(city state) /unique/nomiss));  

See Also

INDEX CREATE Statement in Base SAS Procedures Guide
CREATE INDEX Statement in SAS SQL Procedure User’s Guide
Understanding SAS Indexes in SAS Language Reference: Concepts