Note: If you have an existing data set, you may prefer to create your index using PROC DATASETS. See Creating an index on an existing SAS data set using PROC DATASETS.
For general information regarding INDEXES, please refer to SAS Language Reference, Concepts --> SAS Data Files --> Understanding SAS Indexes. See also
Indexing in the SAS System, Version 6 and
Power Indexing: A Guide to Using Indexes Effectively in Nashville Releases.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
/*****************************************************************************/
/* An index can be created at the same time the data set is created by */
/* using the INDEX= option on the DATA statement. STYLE is a simple index */
/* created on a single variable, STYLE. ROOM is a composite index created */
/* on multiple variables, STYLE and BEDROOMS. */
/* */
/* Indexes can be created on existing data sets by either recreating */
/* the data set and using the INDEX= option, or by using PROC DATASETS. */
/* See SAS Language Reference, Concepts for more general information */
/* about when to create indexes, how to create them, and how to use them. */
/*****************************************************************************/
data houses(index=(style room=(style bedrooms))) ;
input style $1-8 sqfeet 10-13 bedrooms 15 baths 17-19 street $20-36 price $38-45;
datalines;
RANCH 1250 2 1 Sheppard Avenue $64,000
SPLIT 1190 1 1 Rand Street $65,850
CONDO 1400 2 1.5 Market Street $80,050
TWOSTORY 1810 4 3 Garris Street $107,250
RANCH 1500 3 3 Kemble Avenue $86,650
SPLIT 1615 4 3 West Drive $94,450
SPLIT 1305 3 1.5 Graham Avenue $73,650
CONDO 1390 3 2.5 Hampshire Avenue $79,350
TWOSTORY 1040 2 1 Sanders Road $55,850
CONDO 2105 4 2.5 Jeans Avenue $127,150
RANCH 1535 3 3 State Highway $89,100
TWOSTORY 1240 2 1 Fairbanks Circle $69,250
RANCH 720 1 1 Nicholson Drive $34,550
TWOSTORY 1745 4 2.5 Highland Road $102,950
CONDO 1860 2 2 Arcata Avenue $110,700
;
/* When you issue options msglevel=i; , if an index is used, a message */
/* displays in the log specifying the name of the index. */
options msglevel=i ;
/* Test the simple index STYLE */
data simple;
set houses;
where style="RANCH";
run;
/* Test the composite index ROOM */
data composite;
set houses;
where style="CONDO" and bedrooms > 2;
run;
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
partial LOG output 23 data simple; 24 set houses; 25 where style="RANCH"; INFO: Index style selected for WHERE clause optimization. 26 run; NOTE: There were 4 observations read from the data set WORK.HOUSES. WHERE style='RANCH'; NOTE: The data set WORK.SIMPLE has 4 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds 27 data composite; 28 set houses; 29 where style="CONDO" and bedrooms > 2; INFO: Index room selected for WHERE clause optimization. 30 run; NOTE: There were 2 observations read from the data set WORK.HOUSES. WHERE (style='CONDO') and (bedrooms>2); NOTE: The data set WORK.COMPOSITE has 2 observations and 6 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds
Type: | Sample |
Topic: | SAS Reference ==> DATA Step Data Management ==> Access ==> Indexes |
Date Modified: | 2006-05-25 03:02:50 |
Date Created: | 2004-09-30 14:08:57 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | All | n/a | n/a |