Example 5.3 Computing Summary Data and Combining Them with Detail Data

Goal

Summarize several variables in a data set. Add these summarizations to each observation in a data set. Compute new variables by combining summary and detail variables.

Example Features

Featured StepDATA step
Featured Step Options and StatementsMultiple SET statements SET statement with END= option IF _N_=1 statement DO UNTIL loop
Related TechniquePROC SQL, remerging summary statistics
A Closer LookSelecting a Method to Combine Summary and Detail Data

Input Data Set

Data set SESSIONS contains the number of attendees from four groups at each of three training sessions.

                      SESSIONS Data Set

  Obs    session    group_a    group_b    group_c    group_d 1 March 8 29 29 34 2 June 19 3 27 8 3 ...

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.