Announcement

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

  • Multiple individuals per household id number: how to get household information from individual observations

    I am working in a dataset that has both household and individual level variables. We have a total of 1,217 households in the sample. I'm trying to figure out how many households in the sample have had at least 1 individual diagnosed with malaria in the last twelve months. Each household survey asks questions about individuals in the household. So, the variable inm1_malaria is an individual level variable and represents the question "Has NAME been diagnosed with malaria in the last 12 months?
    When I tab inm1_malaria (the individual level variable), I of course get more observations than total number of households in the sample because there are more than 1 individuals per household. When I say: tab hh_no if inm1_malaria==1, I still get more observations than we have households. It's counting each hh_no each time that hh_no is assigned to an individual in the dataset. So if there are 4 individuals with hh_no CHP/02/0004, it is counting that as 4 separate households.
    Any advice on how to get household level data from the individual observations nested within the household would be much appreciated.
    Best,
    Nancy

  • #2
    If you would show us an example of your data set, using the -dataex- command as described in section 12.2 of the FAQ for new participants on StataList (see the tab at the top left of the screen in StataList), a quick and helpful answer would be more likely. Not very many users can give an easy to grasp *verbal* description of a data set, but an example is almost always easy to understand.

    Comment


    • #3
      Mike Lacy gives excellent advice. Nevertheless some strategic hints seem possible.

      https://www.stata.com/support/faqs/d...ble-recording/ may help here.

      A flag for whether any individual has malaria in a household is

      Code:
      egen any_malaria = max(inm1_malaria), by(hhno)
      but to see just households not individuals you need to tag each household just once

      Code:
      egen tag = tag(hhno)
      after which you can

      Code:
      tab any_malaria if tag
      For more information see the help for
      Code:
      egen

      Comment


      • #4
        @Mike, Next time I will definitely post an example of the data set. @Nick, thank you, your code worked! I had started down the correct path trying to use egen, but got stuck.

        Comment


        • #5
          1) geographic in formations like region, zone, woreda, town, kefetegna, kebele, and ea id for each individuals. 2) individual id which is sequentially numbered (e.g. 1, 2,3, ..., for household 1 and 1, 2,3,4,..., for household 2) and restarts from 1 for every households. so how to create unique household id in stata which must be same for individuals within the household and starts from 4032001?

          Comment

          Working...
          X