Assigning Values Conditionally

Categorizing Values

Suppose you want to create a variable that categorizes the length of time that a subject spends on the treadmill during a stress test. This new variable, TestLength, is based on the value of the existing variable TotalTime. The value of TestLength is assigned conditionally:
Value for TotalTime
Resulting Value for TestLength
greater than 800
750 - 800
less than 750
To perform an action conditionally, use an IF-THEN statement. The IF-THEN statement executes a SAS statement when the condition in the IF clause is true.
Syntax, IF-THEN statement:
IF expression THEN statement;
  • expression is any valid SAS expression.
  • statement is any ...

Get SAS Certification Prep Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.