Announcement

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

  • Linking parent's characteristics to children using their ID

    Hello,

    I have some panel data from a household survey and I am trying to link parent's characteristics to their children, such as the parent's nationality for example. Each person in the dataset has multiple rows and the data has already been sorted into households.
    As you can see from the table, children in the dataset have MotherID which gives the PersonID of their mother, yet I am not sure how to use this to give the MothersNationality by matching PersonID and MotherID.

    HouseID PersonID MotherID Nationality MothersNationality
    1 1 English
    1 1 English
    1 1 English
    1 2 Italian
    1 2 Italian
    1 3 1 French
    1 3 1 French
    1 3 1 French
    1 3 1 French
    1 4 1 French
    1 4 1 French
    2 5 Spanish
    2 5 Spanish
    2 6 5 Scottish
    2 6 5 Scottish
    2 6 5 Scottish

    Using this example above, how would I be able to show the MothersNationality as English for PersonID==3 & 4, and Spanish for PersonID==6?

    Thank you in advance for your time,

    Adam




  • #2
    See: https://www.statalist.org/forums/for...ndividual-s-id
    and https://www.statalist.org/forums/for...able-as-mother

    Please post your data sample using -dataex- as described in 12.2 of the FAQ https://www.statalist.org/forums/help#stata
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. I can't really follow your data structure.

      I suspect you want to make a numerical variable that stands for the nationality if the observation is the mother and missing otherwise. Then you can use bysort x: egen meanid=mean(nationality) to put that value across other observations.

      Comment

      Working...
      X