Published on :
Général IMPLICITE

Sans titre

This code is also available in: Deutsch Español Français
The INDEX= data set option allows you to create indexes when creating a new SAS© data set. Indexes can be simple (based on a single variable) or composite (based on multiple variables). Additional options like UNIQUE and NOMISS can be specified to refine index creation. UNIQUE ensures that all key variable values must be unique, while NOMISS excludes observations with missing values for the index variables.
Data Analysis

Type : IMPLICITE


The provided examples focus on the syntax of the INDEX= option and do not include explicit data creation code (datalines or SASHELP), but assume the existence of input data or the creation of new variables.

1 Code Block
DATA STEP
Explanation :
This example shows how to define a simple index on the 'ssn' variable when creating a new data set named 'new'.
Copied!
1 
2DATA new(index=(ssn));
3/* ... more SAS code ... */
4RUN;
5 
2 Code Block
DATA STEP
Explanation :
This example illustrates the creation of a composite index named 'cityst' using the 'city' and 'state' variables for the new data set 'new'.
Copied!
1 
2DATA new(index=(cityst=(city state)));
3/* ... more SAS code ... */
4RUN;
5 
3 Code Block
DATA STEP
Explanation :
This example combines the definition of a simple index on 'ssn' and a composite index on 'city' and 'state' for the new data set 'new'.
Copied!
1 
2DATA new(index=(ssn cityst=(city state)));
3/* ... more SAS code ... */
4RUN;
5 
4 Code Block
DATA STEP
Explanation :
This example shows how to define a simple index on 'ssn' ensuring that all 'ssn' values are unique in the new data set.
Copied!
1 
2DATA new(index=(ssn /unique));
3/* ... more SAS code ... */
4RUN;
5 
5 Code Block
DATA STEP
Explanation :
This example illustrates the creation of a simple index on 'ssn', excluding observations with missing values for this variable from the index in the new data set.
Copied!
1 
2DATA new(index=(ssn /nomiss));
3/* ... more SAS code ... */
4RUN;
5 
6 Code Block
DATA STEP
Explanation :
This example defines a unique and non-missing simple index for 'ssn', as well as a unique and non-missing composite index for 'city' and 'state' in the new data set.
Copied!
1 
2DATA new(index=(ssn /unique/nomiss cityst=(city state) /unique/nomiss));
3/* ... more SAS code ... */
4RUN;
5 
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Banner
Expert Advice
Expert
Michael
Responsable de l'infrastructure Viya.
« In SAS, an index is a powerful auxiliary file that provides direct access to specific observations, drastically reducing the time needed for WHERE clause processing and join operations. While indexes can be added later using PROC DATASETS, the INDEX= data set option allows you to build these structures during the initial creation of the data set, ensuring that your data is "born" optimized for production use. »