Announcement

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

  • Making conditions for other observations

    Good day everybody,
    Could anybody help me? I carry out a research on migration and I need data on spouse, children and parents, left at home. I have only ID's and Relation data. Relation means parent, head, sister, child and so on.
    I have different variables,

    hhid pid Relation MaritalStatus SpouseID Stay SpouseLeft
    2010 1 Head 1 2 0
    2010 2 Wife 1 1 1

    I need to generate new variable with condition for spouse. So I have a person, he has a wife, if this wife stay at home, for this person I need to create variable SpouseLeft with value 1, otherwise 0.
    I did it manually in fact, but I could make mistakes.
    So if anybody could help me I will be very grateful. Thank you in advance.

  • #2
    I set about providing some sample code, but realized your sample data does not address some important issues.

    1) In your data, does each household have exactly one head? I have used survey data where the head is the head of a family, and more than one family can belong to a single household. (For example, a young couple living in the household of the husband's or wife's parents; a single parent with children who is living with the parent's parents.) You can explore this question in your data with
    Code:
    bysort hhid: egen nhead = total(Relation=="Head") 
    list if nhead!=1
    2) If there is a head and no spouse, what would you want the value of "SpouseLeft" to be?

    Comment


    • #3
      Yes, exatly. One household my consist of several families. In some cases migrant maybe not a head but a son or daughter or in some cases grandchild. So it is a big trouble, that is why I filled out values manually.
      It is also a question for me. So some migrants are not married. So I think the value of SpouseLeft" should be 0.

      Comment

      Working...
      X