O'Reilly logo

SAS 9.4 Language Reference, 6th Edition by SAS Institute

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11
WHERE-Expression Processing
Definition of WHERE-Expression Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Where to Use a WHERE Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Syntax of WHERE Expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
WHERE Expression Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Specifying an Operand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Specifying an Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Combining Expressions By Using Logical Operators . . . . . . . . . . . . . . . . . . . . . . . 188
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Processing Compound Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Using Parentheses to Control Order of Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . 189
Improving Performance of WHERE Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Processing a Segment of Data That Is Conditionally Selected . . . . . . . . . . . . . . . . 190
Applying FIRSTOBS= and OBS= Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Applying FIRSTOBS= and OBS= to a Subset of Data . . . . . . . . . . . . . . . . . . . . . 191
Processing a SAS View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Deciding Whether to Use a WHERE Expression or a Subsetting IF Statement . 193
Definition of WHERE-Expression Processing
WHERE-expression processing
enables you to conditionally select a subset of observations, so that SAS processes
only the observations that meet a set of specified conditions. For example, if you
have a SAS data set that contains sales records, you might want to print just the
subset of observations for which the sales are greater than $300,000 but less than
$600,000. In addition, WHERE-expression processing can improve efficiency of a
request. For example, if a WHERE expression can be optimized with an index, it is
not necessary for SAS to read all observations in the data set in order to perform the
request.
WHERE expression
defines a condition that selected observations must satisfy in order to be processed.
You can have a single WHERE expression, referred to as a simple expression, such
as the following:
where sales gt 600000;
177

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required