一、问卷背景:看hhead=1,等于1的为户主,然后看观察值的a2001
若a2001=1,则需要在家庭中找到一个a2001=2的人;
若a2001=2,则需要在家庭中找到一个a2001=1的人;
若a2001=3,则需要在家庭中找到一个a2001=3的人;
若a2001=4,则需要在家庭中找到一个a2001=4的人;
若a2001=5,则需要在家庭中找到一个a2001=5的人;
若a2001=6,则需要在家庭中找到一个a2001=7的人;
若a2001=7,则需要在家庭中找到一个a2001=6的人;
若a2001=8,则需要在家庭中找到一个a2001=9的人;
若a2001=9,则需要在家庭中找到一个a2001=8的人;
若a2001=10,则需要在家庭中找到一个a2001=7777的人;
若a2001=7777,则需要在家庭中找到一个a2001=7777的人;
二、实现代码:sort hhead
recode a2001(2=1)(1 3 4 5 6 7 8 9 10 7777=0) if hhead==1&a2001==1
recode a2001(1=1)(2 3 4 5 6 7 8 9 10 7777=0) if hhead==1&a2001==2
recode a2001(3=1)(1 2 4 5 6 7 8 9 10 7777=0) if hhead==1&a2001==3
recode a2001(4=1)(1 2 3 5 6 7 8 9 10 7777=0) if hhead==1&a2001==4
recode a2001(5=1)(1 2 3 4 6 7 8 9 10 7777=0) if hhead==1&a2001==5
recode a2001(7=1)(1 2 3 4 5 6 8 9 10 7777=0) if hhead==1&a2001==6
recode a2001(6=1)(1 2 3 4 5 7 8 9 10 7777=0) if hhead==1&a2001==7
recode a2001(9=1)(1 2 3 4 5 6 7 8 10 7777=0) if hhead==1&a2001==8
recode a2001(8=1)(1 2 3 4 5 6 7 9 10 7777=0) if hhead==1&a2001==9
recode a2001(7777=1)(1 2 3 4 5 6 7 8 9 10=0) if hhead==1&a2001==10
recode a2001(7777=1)(1 2 3 4 5 6 7 8 9 10=0) if hhead==1&a2001==7777
drop if hhead==a2001#第一步内设会有重叠,可以将这部分样本剔除,当然我也是构建的一个简易代码,如果有更好的想法设计,欢迎一起交流呀
recode a2001(1=1)(2 3 4 5 6 7 8 9 10 7777=0)
gen head_mate=a2001 if a2001==1
recode head_mate(1=1)(.=0)


雷达卡


京公网安备 11010802022788号







