Good morning,
I'm Daniel, thanks for reading this comment. I'm working with a dataset that reports the sibling characteristics of my observations in different columns (find attached with dataex an example using just observations with two siblings _01= first sibling, _02= second sibling). That said, I would like to create 3 different variables, a sum of the siblings, a sum of male siblings, and a sum of female siblings, only for the siblings who are still alive
I tried to use the following command:
Sadly, the asterisk does not work with the "if" condition and I run out of ideas on how to overcome this issue considering that the database contains up to 20 registries for siblings (from _01 to _20).
PD: mm3 is the age of the sibling.
Thank you in advance,
Daniel.
I'm Daniel, thanks for reading this comment. I'm working with a dataset that reports the sibling characteristics of my observations in different columns (find attached with dataex an example using just observations with two siblings _01= first sibling, _02= second sibling). That said, I would like to create 3 different variables, a sum of the siblings, a sum of male siblings, and a sum of female siblings, only for the siblings who are still alive
I tried to use the following command:
Code:
egen sumsiblings=rowtotal(mm1_*) if mm1_*!=. & mm2_*==1 egen summalesiblings=rowtotal(mm1_*) if mm1_*==1 & mm2_*==1 egen sumfemalesiblings=rowtotal(mm1_*) if mm1_*==2 & mm2_*==1
PD: mm3 is the age of the sibling.
Thank you in advance,
Daniel.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(mm1_01 mm2_01 mm3_01 mm1_02 mm2_02 mm3_02) 1 1 13 1 0 . 2 1 32 2 1 29 1 1 34 1 0 . 1 1 13 1 1 11 1 1 35 1 1 32 2 0 . 2 0 . 1 0 . 2 0 . 1 1 11 1 1 8 . . . . . . 2 1 13 1 0 . 2 1 12 1 1 9 2 1 25 1 0 . 1 0 . 2 1 5 2 0 . 1 0 . 1 1 20 1 1 14 1 1 30 1 1 25 1 1 17 1 1 13 2 0 . 1 0 . 2 0 . 2 1 37 2 1 20 1 1 15 1 1 29 2 1 24 1 1 21 1 0 . 2 1 18 2 0 . 1 1 27 1 1 24 1 1 30 2 1 27 1 1 14 2 0 . 2 1 28 2 1 24 2 0 . 2 0 . 1 0 . 1 1 19 1 1 17 1 0 . 2 0 . 2 0 . 1 1 26 2 1 23 2 0 . 1 0 . 1 1 21 2 1 18 1 1 14 2 1 11 1 0 . 2 0 . 2 1 37 2 1 34 1 1 33 1 0 . 2 0 . 2 1 30 2 1 29 1 1 26 2 1 22 2 1 19 2 1 17 2 1 13 1 1 20 2 0 . 2 1 23 1 1 20 1 0 . 1 1 15 1 1 34 1 1 32 2 1 26 1 1 23 1 1 23 1 0 . 1 0 . 1 1 6 1 1 14 1 1 11 2 1 18 1 1 12 1 1 26 1 1 24 1 1 26 1 1 24 1 0 . 2 1 26 1 0 . 1 0 . 2 0 . 1 1 23 2 1 18 1 0 . 1 1 25 1 1 25 1 1 7 . . . 1 1 35 1 1 33 1 1 28 2 0 . 2 0 . 1 0 . 1 1 20 2 0 . 1 1 32 2 0 . 1 0 . 1 1 21 2 0 . 1 1 35 1 0 . 1 1 33 1 1 33 2 1 28 1 0 . 1 0 . 2 1 25 1 1 22 1 1 13 2 1 10 2 0 . 2 1 25 1 1 23 1 0 . 1 1 17 1 1 13 2 1 29 2 1 27 2 1 13 2 1 10 1 1 26 1 1 23 2 1 20 1 1 13 2 1 27 2 1 24 1 1 30 1 1 27 1 0 . 2 1 18 1 1 27 2 1 21 2 1 32 1 1 29 2 0 . 2 1 21 1 0 . 2 1 23 2 1 42 1 1 39 1 0 . 2 1 33 2 0 . 1 0 . 2 1 23 1 1 12 2 0 . 2 0 . 2 1 26 1 1 22 1 0 . 1 1 12 2 1 22 1 0 . 2 1 19 2 1 13 1 1 19 . . . 2 1 11 2 0 . 2 1 18 2 0 . 2 1 27 2 1 24 2 1 25 2 1 22 2 0 . 1 1 8 end label values mm1_01 mm1_01 label def mm1_01 1 "male", modify label def mm1_01 2 "female", modify label values mm2_01 mm2_01 label def mm2_01 0 "dead", modify label def mm2_01 1 "alive", modify label values mm3_01 mm3_01 label values mm1_02 mm1_02 label def mm1_02 1 "male", modify label def mm1_02 2 "female", modify label values mm2_02 mm2_02 label def mm2_02 0 "dead", modify label def mm2_02 1 "alive", modify label values mm3_02 mm3_02


Comment