Example 3.12 Combining and Collapsing Observations Based on a Common Variable
Goal
Reshape a transaction data set by turning related observations into single ones. Match each collapsed observation from the transaction data set with an appropriate observation from the master data set, based on the value of a key variable.
Example 3.13 also combines and collapses observations based on a common variable, but its transaction data set is indexed on the common variable and it uses index features to combine the observations.
Example Features
Featured Step | PROC TRANSPOSE and DATA step |
Featured Step Options and Statements | PROC TRANSPOSE: BY, ID, and VAR statements, PREFIX= option DATA step: match-merge by common variable |
Related Technique | DATA step, arrays, ... |
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.