Announcement

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

  • Assigning head of household value within all members oh household

    Good morning everybody,
    I have a household database and would like to create a new variable. This variable i call it "educHH". This variable should have the value of the level of education of the head of household. It is because I have another variable "men109" which represents the level of education of different members of HH and another one "men108" which represents the status of the member (whether he is the head of household or the son of the head of household,...). the household id is "codmen"
    What I need is "educHH" takes the value of men109 if men108 is head of household. And all members of household should bear the same value.

  • #2
    This is a straightforward question but it remains unanswered because you did not follow the FAQ recommendation to present a data example using dataex. Here, you want us to guess the structure of your data, whether your variables are strings or numerical, whether you have exactly 1 head per household etc. My solution will make the assumption that your data is in long format and that your variables identifying the status of the household members and their levels of education are categorical. Therefore, assuming that you have a variable named "hhid" identifying households, you can create the variable as follows

    Code:
    bys hhid: egen educHH= max(cond(men108==1,men109, . ))
    A further assumption is that the head of the household is assigned a value of 1 (men108==1). If you do not make any progress with this, read the FAQs and act accordingly.

    Comment

    Working...
    X