Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: replace missing in panel data


From   "Dherani, Mukesh" <M.K.Dherani@liverpool.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: replace missing in panel data
Date   Mon, 30 Jun 2008 12:43:36 +0100

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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index