Ha, that's the theory. If only things were that simple.
In fact WHERE clauses are a bit faster than IF tests when simple (equality or inequality) value validations are performed.
But they are slower when functions are used.
16741 data TEST;
16742 do I=1 to 1e8;
16743 output;
16744 end;
16745 run;
16746 data _null_;
16747 set TEST;
16748 if I=1;
16749 run;
real time 5.21 seconds
16750 data _null_;
16751 set TEST;
16752 where I=1;
16753 run;
real time 4.73 seconds
16754 data _null_;
16755 set TEST;
16756 if round(I)=1;
16757 run;
real time 8.40 seconds
16758 data _null_;
16759 set TEST;
16760 where round(I)=1;
16761 run;
real time 16.07 seconds
In this simple test on my PC, WHERE is 10% faster than IF for an equality validation, but 100% slower if a function is used.
I only uncovered these variations last year, and will have to update the third edition of my book.
It looks as if functions compiled as part of the data step are more efficient than functions that process the data buffer before the PDV is loaded.
... View more