Merge hierarchial file with rectangular file

Hello,

Using IPUMS NHIS data, I would like to merge a variable only available in hierarchial format irfallwhy with all my other data in rectangular format (I would like to analyze the data in rectangular form as person-level data). My attempts to merge on year and nhispid as well as hhx fmx pxhave been unsuccessful.

Thanks

You can merge injury variables onto a rectangularized person file using YEAR, SERIAL and PERNUM; these variables are automatically included on injury records in hierarchical datasets. Please note that a person can report multiple injuries, so you will need to pay attention to which dataset you are merging onto to allow for a one-to-many or many-to-one merge between injury and person records. The resulting dataset will be in a long format, and you could iterate through the injury records to summarize information from IRFALLWHY and then remove the injury records.

If you want to keep all the information on each injury record (e.g., a fully rectangularized file rather than using a long file to summarize injury-level information), you will need to reshape your data because each person can have multiple injury records. Assuming you want a fully rectangularized file, it is probably easier to request all variables (household-, person-, and injury-level) in a single, hierarchical extract and reshape that extract (rather than merging a rectangularized person file with a hierarchical injury-file and then reshaping).