Dear all,

I want to supplement the current missing values using the values around it . Below is my code.

foreach x of varlist * {
qui bys id : replace `x'=`x'[_n-1] if missing(`x')
qui bys id : replace `x'=`x'[_n+1] if missing(`x')
}

but it seems not to work. Even I run this code a few times , there still exists missing value. Is there any command to do this job?