Hi, I need to know how many children that are preferred by mom in one household. May anyone suggest the command or the code for this problem?
Let's say if mom have son preference, and in one household, there are 2 boys and 1 girl. So the preferred number of children in one household is equal to 2.
If mom have daughter preference, and there are 2 boys and 1 girl in one household, so the preferred number of children in one household is equal to 1.
hhid is household id, and pid is individual id.
Thank you!
sex : 0 = girl | 1 = boy
sonpref : 0 = mother preferred girl | 1 = mother preferred boy
pid : id for individual
hhid : id for household
Let's say if mom have son preference, and in one household, there are 2 boys and 1 girl. So the preferred number of children in one household is equal to 2.
If mom have daughter preference, and there are 2 boys and 1 girl in one household, so the preferred number of children in one household is equal to 1.
hhid is household id, and pid is individual id.
Thank you!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double pid str8 hhid float sonpref double sex 10 "0021800" 0 0 9 "0030100" 1 1 9 "0030500" 0 0 3 "0031041" 0 1 3 "0031731" 1 0 9 "0032500" 0 0 7 "0032500" 0 0 3 "0032700" 0 1 5 "0032900" 0 1 6 "0032900" 0 0 5 "0043022" 0 0 4 "0051341" 0 1 3 "0051500" 0 1 7 "0051600" 0 0 4 "0060431" 1 1 3 "0060431" 1 0 3 "0061231" 1 0 8 "0061700" 0 1 6 "0071300" 0 1 4 "0072200" 0 1 9 "0072500" 1 1 6 "0080100" 0 1 3 "0081731" 0 0 5 "0082500" 1 0 4 "0082800" 1 1 7 "0082800" 0 0 4 "0082931" 0 0 3 "0082931" 0 0 11 "0090700" 1 0 7 "0090900" 1 0 5 "0090900" 1 1 6 "0091400" 1 1 5 "0091400" 1 1 8 "0091400" 1 0 7 "0091400" 1 0 10 "0091531" 0 1 9 "0092300" 1 0 3 "0092441" 1 0 8 "0092600" 1 1 15 "0102600" 1 0 14 "0102600" 1 0 16 "0102600" 1 1 5 "0102600" 1 0 6 "0102700" 0 1 7 "0102700" 0 0 8 "0102700" 0 0 9 "0102700" 0 0 4 "0104331" 0 0 4 "0111100" 1 0 5 "0111100" 1 1 2 "0112632" 0 0 3 "0112632" 0 1 3 "0120200" 1 0 5 "0120900" 1 0 3 "0121432" 1 1 4 "0121432" 1 1 7 "0141800" 0 0 3 "0141900" 1 0 3 "0150431" 0 0 6 "0150600" 0 0 7 "0150700" 0 1 8 "0150700" 0 1 5 "0171000" 1 1 4 "0180431" 0 1 4 "0180800" 1 0 3 "0180800" 1 1 6 "0180931" 1 0 10 "0191000" 0 0 3 "0191011" 1 0 4 "0191011" 1 0 3 "0201031" 1 0 10 "0201900" 0 1 8 "0202000" 0 1 8 "0210600" 0 1 6 "0210600" 0 0 7 "0210600" 0 0 3 "0211131" 1 1 4 "0211131" 1 1 3 "0220531" 0 1 7 "0222000" 0 0 3 "0231141" 1 1 4 "0242300" 1 1 6 "0242300" 1 1 5 "0242841" 1 1 3 "0250131" 0 1 3 "0251031" 0 0 3 "0251331" 1 0 10 "0251500" 0 1 4 "0260221" 1 0 6 "0270300" 1 0 7 "0270300" 1 0 15 "0270600" 1 1 4 "0270613" 0 1 5 "0270831" 0 1 10 "0271500" 1 1 3 "0272941" 1 0 9 "0280100" 1 1 4 "0281041" 1 0 3 "0291100" 1 0 3 "0291400" 0 1 end
sonpref : 0 = mother preferred girl | 1 = mother preferred boy
pid : id for individual
hhid : id for household

Comment