Example 8.12 Collapsing Observations within a BY Group into a Single Observation
Rearrange a data set by changing selected variables in a group of observations to a group of variables in one observation. Reshape data by collapsing observations within a BY group into a single observation in order to simplify data analysis and report generation.
The example uses the same input data set as Example 8.9.
|Featured Step||DATA step|
|Featured Step Options and Statements||BY statement
FIRST.variable and LAST.variable temporary variablesOUTPUT statement
|Related Technique||PROC TRANSPOSE, PREFIX= option, BY, ID, RETAIN, and VAR statements DATA step, match-merging by value and merging a data set with itself|
Input Data Set
Data set WEIGHT_BMI ...