Hi all,
Bit of a hard one to explain but hopefully I can.
I'm trying to obtain the height of the mother for each child, however as shown in the data below the variable hh_b15 indicates who their mother is in terms of their individual id: indidy2 [with 97-99 being mother not available].
So what I need is a function that uses the "Who's the mother" information and then looks up this mother's height and outputs the value on the same line as the child, but notably per household. If that makes sense?
I've tried this but to no success:
Thanks,
Alex
Bit of a hard one to explain but hopefully I can.
I'm trying to obtain the height of the mother for each child, however as shown in the data below the variable hh_b15 indicates who their mother is in terms of their individual id: indidy2 [with 97-99 being mother not available].
So what I need is a function that uses the "Who's the mother" information and then looks up this mother's height and outputs the value on the same line as the child, but notably per household. If that makes sense?
I've tried this but to no success:
Code:
by y2_hhid: egen mother_height = max(hh_u04) if indidy2 == hh_b15
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str16 y2_hhid byte indidy2 double hh_u04 byte(hh_b12 hh_b15) float age "0101014002017101" 1 160.60000610351563 98 98 70 "0101014002017101" 2 141.6999969482422 98 98 60 "0101014002017101" 3 . 1 2 27 "0101014002017101" 4 167.39999389648438 1 2 20 "0101014002017101" 5 . 98 97 8 "0101014002028401" 1 164.3000030517578 98 98 38 "0101014002028401" 2 141.60000610351563 98 97 22 "0101014002028401" 3 91.30000305175781 1 2 4 "0101014002028401" 4 44.20000076293945 1 2 0 "0101014002029701" 1 175.10000610351563 98 98 52 end label values hh_b12 hh_b12 label def hh_b12 98 "Dead", modify label values hh_b15 hh_b15 label def hh_b15 97 "Living out of the household", modify label def hh_b15 98 "Dead", modify
Thanks,
Alex
Comment