Example 8.1 Performing a Simple Subset

Goal

Create a subset of a SAS data set efficiently by selecting for processing only observations that meet a particular condition.

Example Features

Featured StepDATA step
Featured Step Options and StatementsWHERE statement
Related TechniquePROC SQL, WHERE clause
A Closer LookComparing the WHERE Statement in the DATA Step and the Subsetting IF Statement

Input Data Set

Data set CELLPHONES contains the support records for one day. Only the first 25 of 10,000 observations are shown.

                           CELLPHONES

  Obs   callhour   calllength     status       reason 1 00 10 Resolved Text Msg Help 2 00 2 Transferred Other Feature Help 3 01 3 Resolved Start Service 4 01 2 Resolved Other 5 01 4 Resolved Voice Mail Help 6 01 4 Resolved Billing Change ...

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.