Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Merge households and individuals datasets

    I am using a dataset divided into several different files, some of those are at the household level and some at the individual level. I want to work at the individual level but having information from the households too, but I am having problem merging files with two different levels. Households are identified by a code, let's say "hhid", and individual by both households and individual code "indid".
    Just to show an example:

    hh.dta
    hhid
    1
    2
    3
    4

    ind.dta
    hhid indid
    1 1
    1 2
    2 1
    3 1
    4 1
    4 2
    4 3

    How can I merge the two files, in a way in which the variable of the household is matched to all individuals in that household?
    I hope my question is enough clear, thanks!

  • #2
    it appears that your hh data has only 1 occurrence of each id while your indid data may have more than one occurrence of each hhid; thus, if your hh data is in memory use a 1:m merge while if your ind data is in memory use an m:1 merge; see
    Code:
    help merge

    Comment

    Working...
    X