请教两个命令
householdnumber line(household下的个人) year income father mother
211 1 1991 200 . .
211 1 1993 300 . .
211 2 1993 320 1 1
212 1 1993 200 . .
212 1 1995 230 . .
212 2 1993 210 . .
如上panel data 请问如何写code得到下面两个结果
(1) drop 掉 father 和mother 同时等于缺失值的同一household的所有个人的观测值。
如上表的212应删除
,
如果在同一个household下只要出现father和mother的非缺失值
则保留该household的信息
即上表中211household中的所有个人信息
我用的语句是
gen n=1; bys householdnumber: egen size=sum(n) if father==1 | mother==1; drop if n~=. 可是如果这样211 1中的两个个人观测值也都被删了
不知code该如何写才正确呢?
(2)
在同一个household的同一个年份下
如 obs housenumber line year inc fa mo
1。 211 1 1993 300 . .
2。 211 3 1993 200 1 1
只对fa mo为缺失值的observation进行回归
但是回归时inc需用同一household下
相同年份的父母收入替代
如observation1中的300 需用 2中的200代替
也就是说用父母的收入做小孩收入的工具变量
请问code该如何写?
非常感谢!


雷达卡




京公网安备 11010802022788号







