Chapter Contents

Previous

Next

Deciding Whether to Use a WHERE Expression or a Subsetting IF Statement

To conditionally select observations from a SAS data set, you can use either a WHERE expression or a subsetting IF statement. While they both test a condition to determine if SAS should process an observation, they differ as follows:

In most cases, you can use either method. However, the following table provides a list of tasks that require you to use a specific method:

Tasks Requiring Either WHERE Expression or Subsetting IF Statement
If you want to ... Use a ...
Make the selection in a procedure without using a preceding DATA step WHERE expression
Take advantage of the efficiency available with an indexed data set WHERE expression
Use one of a group of special operators, such as BETWEEN-AND, CONTAINS, IS MISSING or IS NULL, LIKE, SAME-AND, and SOUNDS LIKE WHERE expression
Base the selection on anything other than a variable value that already exists in a SAS data set, for example, on a value that is read from raw data or on a value that is calculated or assigned during the course of the DATA step subsetting IF
Make the selection at some point during a DATA step rather than at the beginning subsetting IF
Execute the selection conditionally subsetting IF


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.