logo Getting Started with SAS Main menuGlossaryBackNext


In your DATA step programs, you'll probably want to use conditional logic to process some observations but not others.

Using conditional statements

To execute a SAS statement for observations that meet specific conditions, you can use

  • IF-THEN/ELSE statements for programs with few conditional statements
  • a SELECT group when you have a long series of mutually exclusive conditions
  • subsetting IF statements, without a THEN clause, to continue processing only those observations or records that meet the condition that is specified in the IF clause.

To construct expressions in statements, you can use these comparison operators:

Operator Comparison Operation
= eq equal to
^= ne not equal to
> gt greater than
< lt less than
>= ge greater than or equal to
<= le less than or equal to
  in equal to one of a list

You can also use these logical operators:

Operator Logical Operation
& and
| or
^ or ~ not

Main menuGlossaryBackNext