Hello all,
I have duplicates (based on ID and date) in my panel dataset along with missing information for many variables. I want to replace missing information with either previous [_n-1] or following [_n+1] row. The problem is that the variables are not all numeric, some of them are string. I wonder is there any way I can replace both types of variables in one go?
foreach var in a1-z1{
replace `var'=`var'[_n-1] if `var'==. & duplicate==1
replace `var'=`var'[_n+1] if `var'==. & duplicate==1
}
Thanks you in advance,
BW,m
Dr.Mukesh K Dherani
Research Fellow
Department of Public Health
Whelan Building
Liverpool L69 3GB
Tel:+44 (0) 151 794 5591
Fax:+44 (0) 151 794 5588
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/