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.
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 | |
| 2 | DATA new(index=(ssn)); |
| 3 | /* ... more SAS code ... */ |
| 4 | RUN; |
| 5 |
| 1 | |
| 2 | DATA new(index=(cityst=(city state))); |
| 3 | /* ... more SAS code ... */ |
| 4 | RUN; |
| 5 |
| 1 | |
| 2 | DATA new(index=(ssn cityst=(city state))); |
| 3 | /* ... more SAS code ... */ |
| 4 | RUN; |
| 5 |
| 1 | |
| 2 | DATA new(index=(ssn /unique)); |
| 3 | /* ... more SAS code ... */ |
| 4 | RUN; |
| 5 |
| 1 | |
| 2 | DATA new(index=(ssn /nomiss)); |
| 3 | /* ... more SAS code ... */ |
| 4 | RUN; |
| 5 |
| 1 | |
| 2 | DATA new(index=(ssn /unique/nomiss cityst=(city state) /unique/nomiss)); |
| 3 | /* ... more SAS code ... */ |
| 4 | RUN; |
| 5 |