Support #1882

Linking individual and household data and analysing at a household level

Added by Matty Grassow about 1 year ago. Updated 7 months ago.

Data management
Start date:
% Done:



Hi there!

Do let me know if this is the wrong place to be asking but I'm currently doing some analysis using wave 12 and am trying to link individual and household data. I've managed to do this using the 'l_hidp' variable however as the analysis I've been doing has been household level, I'm unsure how I can do this now the datasets are merged?

Specifically, I've been looking at the 'l_elecpay', 'l_tenure_dv', 'l_ncars' and 'l_xphsdba' variables to calculate the number of households affected by certain characteristics (e.g. in rented accommodation, on pre-payment meter etc.). In merging it with individual level data, I'm wanting to look at the number of households who also (in addition to the above four variables) have someone in them with a long-standing illness or impairment (using 'l_health').

If this is possible I'd really appreciate any help you can give.

Thank you very much,


Updated by Understanding Society User Support Team about 1 year ago

  • Category set to Data management
  • Status changed from New to Feedback
  • % Done changed from 0 to 80
  • Private changed from Yes to No


If I understand correctly what you want to do then you started with a household level file, then linked an individual level file, assuming you didn't do anything else you then still worked with an individual level file. So, to calculate that new household level variable about the disability you need aggregate the individual-level information to the household, e.g. in Stata:

bysort l_hidp: egen l_disabbin = max(l_health==1)
bysort l_hidp: egen l_disabbinmiss = max(l_health==.)
replace l_disabbin=. if l_disabbinmiss
lab var l_disabbin "Any of HH members disabled"

If you want the number of people then use sum() rather than max. Finally, if you want to get a household level file at the end then you can keep just one row per each household:

bysort l_hidp: keep if _n==1

If you need to do that in other software have a look at our online Moodle Introduction to Understanding Society using R, Stata, SPSS and SAS, you can find here, it's free of charge but you need to register first, though it doesn't take too much time.

I hope it helps.

Best wishes,
UKHLS User Support


Updated by Understanding Society User Support Team 7 months ago

  • Status changed from Feedback to Resolved
  • % Done changed from 80 to 100

Also available in: Atom PDF