# Merging Hierarchical and Rectangular Data

**URL:** <https://forum.ipums.org/t/merging-hierarchical-and-rectangular-data/6759>\
**Category:** HEALTH SURVEYS\
**Created:** [September 9, 2025, 8:41pm UTC](https://forum.ipums.org/t/merging-hierarchical-and-rectangular-data/6759 "2025-09-09T20:41:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Camille\_Wixon](https://avatars.discourse-cdn.com/v4/letter/c/c57346/32.png) [@Camille\_Wixon](https://forum.ipums.org/u/Camille_Wixon)\
**Post date:** [September 9, 2025, 8:41pm UTC](https://forum.ipums.org/t/merging-hierarchical-and-rectangular-data/6759/1 "2025-09-09T20:41:15Z")

</div>

Hi,

I am trying to match Diagnosis codes from MEPS (hierarchical data) with limited demographic information (age and sex). The listed IDs in the hierarchical files do no match the IDs in the rectangular. Is there a way to merge these? Am I erring in someway?

Thank you!

---

<div class="post-metadata">

**Author:** ![Ivan\_Strahof](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.ipums.org/ivan_strahof/32/626_2.png) [@Ivan\_Strahof](https://forum.ipums.org/u/Ivan_Strahof)\
**Post date:** [September 12, 2025, 7:28pm UTC](https://forum.ipums.org/t/merging-hierarchical-and-rectangular-data/6759/2 "2025-09-12T19:28:30Z")

</div>

It sounds like you are trying to merge data on the condition record (condition codes [ICD10CODE](https://meps.ipums.org/meps-action/variables/ICD10CODE#description_section)/[ICD9CODE](https://meps.ipums.org/meps-action/variables/ICD9CODE)) with demographic data on the person record. These two record types can be linked using the unique person-level identifier [MEPSID](https://meps.ipums.org/meps-action/variables/MEPSID#description_section) and [MEPSIDX](https://meps.ipums.org/meps-action/variables/MEPSIDX#description_section), the same person-level identifier as reported on the condition record.

Note that it is possible to include both person-level and condition-level records in a single file from IPUMS MEPS by selecting a hierarchical file type and adding variables from these record types. For instance, if you request an extract with the variables AGE, SEX, and the above condition codes, your extract will include all of these in a single data file, where the condition record will be nested under the corresponding person record. In the screenshot below (copied from the [extract structures note](https://meps.ipums.org/meps/userNotes_extractStructures.shtml) from [our user guide](https://meps.ipums.org/meps/userGuide.shtml)), the hierarchical data file nests the condition records ([RECTYPE](https://meps.ipums.org/meps-action/variables/RECTYPE#codes_section) = X), event records, and round records under the person record that they correspond to.

 ![Screenshot of MEPS hierarchical file](https://us1.discourse-cdn.com/flex019/uploads/ipums/original/2X/9/905d39e2c9debf2ae515b2a635420514535deede.png)
