Assigning Values Conditionally

Overview

In the previous section, you created the variable SumSec by using a sum statement to add total seconds from treadmill stress. This time, let's create a variable that categorizes the length of time that a subject spends on the treadmill during a stress test. This new variable, TestLength, will be based on the value of the existing variable TotalTime. The value of TestLength will be assigned conditionally:
If TotalTime is . . .
then TestLength is . . .
greater than 800
Long
750 - 800
Normal
less than 750
Short
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.

Get SAS Certification Prep Guide: Base Programming for SAS 9, Third Edition now with O’Reilly online learning.

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