Example 8.16 Obtaining Hierarchical Data from a Table and Matching Them to the Rows in the Same Table


Identify hierarchically related rows in a table. For each group of hierarchically related rows, extract data from the row that is at the higher level of the hierarchy and join these values to all rows in the group.

Example Features

Featured StepPROC SQL
Featured Step Options and StatementsSelf-join, WHERE clause
Related TechniqueDATA step, match-merging a data set with itself

Input Table

Table PERSONS records survey information about persons in households. It has data for four households. The respondent to the survey has a value of "reference" for column RELATIONSHIP. These rows are considered at the higher level of the hierarchy within ...

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.