While school is out (for most) for the summer, many will find this week's SAS Author's tip to be a good primer or refresher about the WHERE statement. Our featured author Sandra Schlotzhauer draws on her extensive career teaching basic statistics to non-statisticians in sharing lessons for grown-ups in her book Elementary Statistics Using SAS.
The following excerpt is from SAS Press author Sandra Schlotzhauer's book Elementary Statistics Using SAS Copyright © 2009, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. (please note that results may vary depending on your version of SAS software)
Understanding the WHERE Statement
The WHERE statement is the simplest way to subset data. This statement specifies the observations to include in the analysis. SAS excludes observations that do not meet the criteria in the WHERE statement. SAS documentation provides details on using the WHERE statement with procedures. The list below gives a brief summary of the
- The WHERE statement can help your programs run faster because SAS uses only the observations that meet the criteria in the WHERE statement. This advantage can be very helpful with large data sets.
- The WHERE statement uses unformatted values of variables, so you need to specify unformatted values in the statement.
- You can use the WHERE statement with any SAS procedure.
- The WHERE statement allows all of the usual arithmetic and comparison operators. For example, you can add, subtract, multiply, and divide in the statement. You can specify comparison operators like equal to, not equal to,
greater than, and so on.
- The WHERE statement has special operators that are available only in the statement. Three operators that are especially useful are IS MISSING, BETWEEN-AND, and CONTAINS.
You can read a free chapter from this book as well as reviews on Sandra's author's page!