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 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.