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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.