clear input ID year var1 var2 var3 1 2006 34 45 65 1 2007 45 43 41 1 2007 3 56 59 1 2008 39 54 76 1 2009 41 57 68 end save "data00.dta", replace use "data00.dta", clear *-删除重复值 (数据有误) . drop if year == 2007 . tsset ID year . tsfill . list // +--------------------------------+ // | ID year var1 var2 var3 | // |--------------------------------| // 1. | 1 2006 34 45 65 | // 2. | 1 2007 . . . | // 3. | 1 2008 39 54 76 | // 4. | 1 2009 41 57 68 | // +--------------------------------+ *-填充缺失值: forv i = 1/3 { tssmooth ma v`i' = var`i' , w(1, 0, 1) replace var`i' = v`i' if var`i' == . } drop v? list // // +--------------------------------+ // | ID year var1 var2 var3 | // |--------------------------------| // 1. | 1 2006 34 45 65 | // 2. | 1 2007 36.5 49.5 70.5 | // 3. | 1 2008 39 54 76 | // 4. | 1 2009 41 57 68 | // +--------------------------------+
标签:填充,手工,+--------------------------------+,45,41,2007,STATA,year,ID From: https://www.cnblogs.com/xkdn/p/17217544.html