Reading Raw Data |
Subsetting
Data![]() ![]() |
Now that you have read the raw data file, you might want to process only those observations that meet a specified condition. To do this, you can use a subsetting IF statement in any DATA step. |
General form, subsetting IF statement:
where expression is any valid SAS expression. The subsetting IF statement causes the DATA step to continue processing only those raw data records or observations that meet the condition of the expression specified in the IF statement.
The resulting SAS data set or data sets contain a subset of the original external file or SAS data set. |
For example, the subsetting IF statement below selects only
observations whose values for Tolerance are D. |
data clinic.stress; infile tests; input ID 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33 RecHR 35-37 TimeMin 39-40 TimeSec 42-43 Tolerance $ 45; if tolerance='D'; run; |
Because Tolerance is a character variable , the
value D must be enclosed in quotes and be the same case as in the
data set. |
![]() |
Refer to the SAS language reference documentation for a comparison of the WHERE and subsetting IF statements when they are used in the DATA step. |
![]() ![]() ![]() ![]() ![]() ![]() |
|
![]() |
![]() |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.