Dear Statalister,
I encounter a problem when I try to create a sample of couples over 2 years (2013 and 2015). I restrict to couples who: 1) both worked in 2013; 2) oberserved in both 2013 & 2015; 3) aged above 25 in 2013, and 4) had relationship as householdhead and spouse
(id refers to individual id, hhid refers to household id)
Code:
When I change the order of restriction [for example 1) aged above 25 in 2013 ; 2) had relationship as household and spouse ; .....], I got different number of couples.
I tried different way but I could not get a sample of couples with equal male and female, equal household head and spouse, and equal numbers of individuals observed in 2013 and 2015.
I guess my codes might be wrong somewhere.
I would appreciate any advice on this.
Thanks in advance.
I encounter a problem when I try to create a sample of couples over 2 years (2013 and 2015). I restrict to couples who: 1) both worked in 2013; 2) oberserved in both 2013 & 2015; 3) aged above 25 in 2013, and 4) had relationship as householdhead and spouse
(id refers to individual id, hhid refers to household id)
Code:
Code:
use fulldataset, replace keep if worked_2013==1 duplicates tag id2013 if (year==2013 | year==2015), gen(dup1315) gen d1315=(dup1315==1) keep if d1315==1 keep if age2013>=25 gen temp = 1 if relationship ==1 replace temp = 2 if relationship == 2 egen couple = total(temp) if (relationship ==1 | relationship == 2), by (hhid2013 year) keep if couple ==3
I tried different way but I could not get a sample of couples with equal male and female, equal household head and spouse, and equal numbers of individuals observed in 2013 and 2015.
I guess my codes might be wrong somewhere.
I would appreciate any advice on this.
Thanks in advance.
Comment