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

Get Step-by-Step Programming with Base SAS 9.4 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.