The Subsetting IF Statement

To select only those observations that meet a specified condition, you can use a subsetting IF statement in any DATA step.

General form, subsetting IF statement:
IF expression;  

where expression is any valid SAS expression.

  • If the expression is true for the observation, the current observation is written to the output data set.

  • If the expression is false, the current observation is not written to the output data set.


For example, the subsetting IF statement below selects only observations whose values for PLACEBO are YES.

     data lab23.drug1h;
        set research.cltrials;
        if placebo='YES';
     run; 

Because the variable PLACEBO is a character variable, the value YES must be enclosed in quotes and be the same case as in the data set.





Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement