真能回复了
不用题主这么麻烦。
sum beginyear endyear
比如beginyear最小值2000,endyear最大值2020
那么,
forvalues i = 2000/2020{
gen year`i' = .
}
forvalues i = 2000/2020{
replace year`i' = 1 if `i' >= beginyear & `i' <= endyear
}
reshape long year, i(id) j(year)
keep if year != .