Creating and Modifying Variables

Accumulating Totals

It is often useful to create a variable that accumulates the values of another variable.
Suppose you want to create the data set Clinic.Stress and to add a new variable, SumSec, to accumulate the total number of elapsed seconds in treadmill stress tests.
Clinic.Stress Data Set
Clinic.Stress Data Set
To add the result of an expression to an accumulator variable, you can use a sum statement in your DATA step.
General form, sum statement:
variable+expression;
where
  • variable specifies the name of the accumulator variable. This variable must be numeric. The variable is automatically set to 0 before the ...

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.