O'Reilly logo

Combining and Modifying SAS® Data Sets: Examples Second Edition by Michele M. Burlew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Example 8.12 Collapsing Observations within a BY Group into a Single Observation

Goal

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.

Example Features

Featured StepDATA step
Featured Step Options and StatementsBY statement

FIRST.variable and LAST.variable temporary variables

OUTPUT statement
Related TechniquePROC 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required