O'Reilly logo

Step-by-Step Programming with Base SAS 9.4 by SAS Institute

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accumulating a Total for an Entire Data Set

Creating a Running Total

The first task in performing calculations on the data set MYLIB.TOURREVENUE is to find the total number of people who booked tours with Tradewinds Travel. Therefore, a variable is needed whose value starts at 0 and increases by the number of bookings in each observation. The Sum statement gives you that capability:
variable + expression
In a Sum statement, the value of variable on the left side of the plus sign is 0 before the statement is processed for the first time. Processing the statement adds the value of expression on the right side of the plus sign to the initial value. The Sum variable retains the new value until the next processing of the statement. The Sum statement ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required