Hi,
I've got this example dataset where the dyads can be followed through census years. I would like to generate a variable "oldest" (0,1) to identify the oldest member of a dyad for each year they appear. The dataset comprises many dyads.
I attempted something like this :
(and many other tests) but it's not working.
Thanks for your help
I've got this example dataset where the dyads can be followed through census years. I would like to generate a variable "oldest" (0,1) to identify the oldest member of a dyad for each year they appear. The dataset comprises many dyads.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long dyad int census long ego byte ego_age 27266 4 617847 3 27266 5 617847 13 27266 5 1001460 33 27266 4 1001460 23 end label values census census label def census 4 "1891", modify label def census 5 "1901", modify
Code:
bysort census dyad (ego_age): egen oldest = max(ego_age)
Thanks for your help

Comment