>> Correct answer: b
>>
>> Explanation - An index can improve the efficiency with which
>> SAS is able to access certain observations in a data set.
>> However, an index is not always useful. SAS will not use an
>> index to process subsetting IF statements, or other
>> statements that SAS determines might be more efficiently
>> processed without an index.
>>
>Hari, well that is just one of literally thousands of good reasons that
>you should just drop everything and order my SAS Index book right now.
>As a matter of fact, do not finish reading this posting--go and order
>the book--I will be waiting for you right here with the rest of the
>message. Go on, you know that you want to!
>
>...okay, ordered it? Then, read on. (If not, then delete this message,
>because I do not want you to get the following information for free).
>
>So, here is how I would think about the choices:
>
>a. The NE operator would likely qualify too many observations in a large
>SAS data set with a normal distribution of flightid's. SAS indexes are
>built to qualify and return a subset of observations--the smaller, the
>better. So, the NE operator is not one of the constructs that triggers
>SAS's use of indexes.
>
>b. We have a winner here, folks! Okay index, start walking!
Here's a contrived example where the heuristics don't work out and the
"winner" is actually a loser.
data with_index(index=(i) ) without_index;
do i = 1 to 1e7; output; end;
run;
data subset;
set without_index;
where I > 2;
run;
data subset;
set with_index;
where I > 2;
run;
On my machine the step which uses the index takes twice as much time as the
one which does not.
>
>C. You are correct; IF statements are not optimized by SAS indexes; not
>ever; no way, now how!
That's because indexes are used in reading data and subsetting IF statements
have to do with flow of control in the DATA step, an utterly different part
of processing.
>
>D. The OR condition is not on a single variable, but on two different
>ones, so SAS will not consider using an index.
That's because every observation has to be examined anyway to see if the
value of ORIGIN satisfies the WHERE condition.
What would happen if there were an index on ORIGIN in addition to the one on
FlightID? Would SAS then use the two indexes together in order to pull the
correct subset?
> If it were a string of
>OR statements with the same variable being tested on each OR (and an
>index were involved), SAS would consider using the relevant index.
>
>Now that my SAS Index book is headed your way, I can point you at
>Chapter 10: Using Indexes with a WHERE Expression, pages 134 - 136,
>Rules for SAS Using a Simple Index.
>
>Hari, best of luck to you on the final grade for your SAS exam!
>
>
>I hope that this suggestion proves helpful now, and in the future!
>
>Of course, all of these opinions and insights are my own, and do not
>reflect those of my organization or my associates. All SAS code and/or
>methodologies specified in this posting are for illustrative purposes
>only and no warranty is stated or implied as to their accuracy or
>applicability. People deciding to use information in this posting do so
>at their own risk.
>
|