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