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

Goal

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 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.