SAS enforces a strict naming convention for Simple Indexes (indexes on a single column) that differs from many other databases. As shown in your first code example (create index area on newcountries(area)), a simple index must share the exact same name as the variable it indexes. If you try to give it a custom name (e.g., create index my_idx on newcountries(area)), SAS will reject it. However, Composite Indexes (on multiple columns) must have a unique name that is distinct from any column in the table.
Type : CREATION_INTERNE
Examples use generated data (CREATE TABLE ... LIKE) from an implicitly available table (COUNTRIES, often from SASHELP) or created tables.
| 1 | PROC SQL; |
| 2 | create TABLE newcountries |
| 3 | like countries; |
| 4 | create index area |
| 5 | on newcountries(area); |
| 6 | QUIT; |
| 1 | PROC SQL; |
| 2 | create index places |
| 3 | on newcountries(name, continent); |
| 4 | QUIT; |
| 1 | PROC SQL; |
| 2 | create TABLE newcountries |
| 3 | like countries; |
| 4 | create unique index places |
| 5 | on newcountries(name, continent); |
| 6 | QUIT; |
| 1 | |
| 2 | PROC SQL; |
| 3 | drop index places from newcountries; |
| 4 | QUIT; |
| 5 |