Example 5.5 Calculating Totals across a BY Group to Produce Cumulative and Grand Totals

Goal

Create in one DATA step two data sets that summarize information found in one data set. Create one data set that contains cumulative totals for observations within a BY group. Create another data set that collapses each BY group into a single observation and produces grand totals for variables in each BY group.

Example Features

Featured StepDATA step
Featured Step Options and StatementsBY-group processing Accumulator variables
Related TechniquePROC SQL, GROUP BY clause, CASE expression, MAX and SUM functions

Input Data Set

Data set TECHCERTIF contains certification-eligible events for five technologists.

 TECHCERTIF event_ Obs techid event_date event_type ...

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.