我有一个7年的不平衡小组,每个受访者都是4次,我想放弃所有报告他们在所有4个时期都失业/不活动的人。但是,我不想放弃在接受采访的4个时期内可能已经离开劳动力市场1,2或3个人的观察结果。我如何告诉Stata在多年(t到t-3)的基础上放弃他们的情况?例如,当我drop if ecostatus>3
时,Stata会删除我需要的观察结果,即那些在整个调查期间不活动的人。
答案 0 :(得分: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