【问题标题】:Dropping people in Stata from a panel based on their situation in multiple years根据多年的情况从小组中删除 Stata 中的人员
【发布时间】:2014-06-13 10:23:12
【问题描述】:
我有一个 7 年的不平衡小组,每个人都接受了 4 次采访,我想删除所有报告他们在所有 4 个时期都失业/不活跃的人。但是,我不想放弃在接受采访的 4 个时期中可能已经离开劳动力市场 1、2 或 3 个时期的人们的观察。我如何告诉 Stata 根据他们多年的情况(t 到 t-3)放弃他们?例如,当我执行drop if ecostatus>3 时,Stata 会丢弃我需要的观察结果,即在整个调查期间内不活动的人。
【问题讨论】:
标签:
panel
stata
economics
【解决方案1】:
// create some example data
clear
input id t unemp
1 1 1
1 2 1
1 3 1
1 4 1
2 1 1
2 2 0
2 3 1
2 4 1
end
// create the total number of unemployment spells
bys id : egen totunemp = total(unemp)
// display the data
sort id t
list, sepby(id)
// keep those observations with at least one
// employment spell
keep if totunemp < 4
// display the data
list