Sample 25637: Creating an index on an existing SAS data set using PROC DATASETS
Create a composite and simple index using PROC DATASETS.
Note: See also
Creating indexes on a SAS data set in a DATA Step.
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.
/* Create test data set */
data houses;
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
;
/* Use the INDEX CREATE statement of PROC DATASETS to create simple index */
/* on the STYLE variable. */
proc datasets library=work;
modify houses ;
index create style ;
run ;
/* MSGLEVEL=I will allow notes to be written to the log indicating whether */
/* the index is used. */
options msglevel=i ;
data temp ;
set houses ;
where style='RANCH' ;
run ;
/* Use the INDEX CREATE statement of PROC DATASETS to create composite index */
/* called ROOM using variables STYLE and BEDROOMS. */
proc datasets library=work;
modify houses ;
index create room=(style bedrooms) ;
run ;
options msglevel=i ;
data temp ;
set houses ;
where style='RANCH' ;
run ;
data temp ;
set houses ;
/* Note - No Index will be selected for use here. See log. */
where bedrooms=3 ;
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
861 data temp ;
862 set houses ;
863 where style='RANCH' ;
INFO: Index style selected for WHERE clause optimization.
864 run ;
NOTE: There were 4 observations read from the data set WORK.HOUSES.
WHERE style='RANCH';
NOTE: The data set WORK.TEMP has 4 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.03 seconds
...
...
...
872 data temp ;
873 set houses ;
874 where style='RANCH' ;
INFO: Index style selected for WHERE clause optimization.
875 run ;
NOTE: There were 4 observations read from the data set WORK.HOUSES.
WHERE style='RANCH';
NOTE: The data set WORK.TEMP has 4 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
876
877 data temp ;
878 set houses ;
879 /* Note - No Index will be selected for WHERE optimization in this sample */
880 where bedrooms=3 ;
881 run ;
NOTE: There were 4 observations read from the data set WORK.HOUSES.
WHERE bedrooms=3;
NOTE: The data set WORK.TEMP has 4 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds
Create a composite and simple index using PROC DATASETS.
Type: | Sample |
Topic: | Data Management ==> Access ==> Indexes SAS Reference ==> Procedures ==> DATASETS
|
Date Modified: | 2005-12-16 03:03:01 |
Date Created: | 2005-07-06 14:11:47 |
Operating System and Release Information
SAS System | Base SAS | All | n/a | n/a |