Specifying Lengths for Variables

Overview

Previously, you added IF-THEN and ELSE statements to a DATA step in order to create the variable TestLength. Values for TestLength were assigned conditionally, based on the value for TotalTime.
data clinic.stress; 
   infile tests; 
   input ID $ 1-4 Name $ 6-25 RestHR 27-29 MaxHR 31-33
         RecHR 35-37 TimeMin 39-40 TimeSec 42-43
         Tolerance $ 45; 
   TotalTime=(timemin*60)+timesec; 
   retain SumSec 5400; 
   sumsec+totaltime; 
   if totaltime>800 then TestLength='Long'; 
   else if 750<=totaltime<=800 then TestLength='Normal'; 
   else if totaltime<750 then TestLength='Short'; 
run;
But look what happens when you submit this program.
During compilation, when creating a new character variable in an assignment statement, SAS allocates ...

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.