Example 8.11 Expanding Single Observations into Multiple Observations

Goal

Reshape data by creating multiple observations from a single observation in the input data set and by assigning variable names as values in the output data set.

Example Features

Featured StepDATA step
Featured Step Options and StatementsOUTPUT statement VNAME variable information call routine
Related TechniquePROC TRANSPOSE, NAME= option, BY statement

Input Data Set

Data set CUSTRESP contains survey results for 25 customers on the number of visits to three sites that resulted in sales.

                    CUSTRESP

    Obs    customer    website    store    event 1 1 0 1 1 2 2 0 8 . 3 3 0 4 0 4 4 10 3 2 5 5 1 . 0 6 6 3 0 0 7 7 0 6 1 8 8 0 2 3 9 9 0 1 0 10 10 0 4 0 11 11 6 4 1 12 12 4 4 2 13 13 9 3 5 14 ...

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.