Loading...

Difference between IF and WHERE


One can subset dataset using IF or WHERE statement to select specific observations from existing SAS data sets in order to create a new SAS data set that includes only some of the observations from the input data source.
Let us explore difference between IF and WHERE at the ground level, below figure will explain processing of IF and WHERE at PDV level.

As shown in the figure, WHERE conditions are applied before the data enters the input buffer while IF conditions are applied after the data enters the program data vector. This is the reason why the WHERE condition is faster because not all observations have to be read and because it can only be applied on variables that exist in the input data set.

Data-set


Since WHERE is applied before PDV so it makes automatic and new variables created in data step inaccessible to WHERE statement, following table will summarize conditions where IF and WHERE statements can be used –
Difference-of-Where-and-If

VirtualNuggets 491723618489834147

Post a Comment

emo-but-icon

Home item

Blog Archive

Popular Posts

Random Posts

Flickr Photo