Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Eric Booth <ebooth@ppri.tamu.edu> |

To |
"<statalist@hsphsun2.harvard.edu>" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: Replacing missing values only works one way? |

Date |
Wed, 28 Jul 2010 01:30:38 +0000 |

<> Please provide an example of your data and the commands you're attempting--it's not clear from your description what "doesn't work" about these commands. Both commands you provided do work: ********! sysuse auto, clear keep rep78 recode rep78 (1=.a) clonevar rep79 = rep78 *** replace rep78 = rep78[_n-1] if rep78>=. replace rep79 = rep79[_n+1] if rep79>=. ********! What you might mean is that these commands don't always fill in all the missing values. This is probably happening when you have a run of missings down a column. So, in the example below, "x" won't be filled in because there are no previous non-missing observations and "y" won't be filled in until there the next value is non-missing: **********! clear inp x y . 1 . 2 2 . 3 . 4 . 5 6 end replace x = x[_n-1] if mi(x) replace y = y[_n+1] if mi(y) ***********! ~ Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University ebooth@ppri.tamu.edu Office: +979.845.6754 On Jul 27, 2010, at 4:13 PM, Dana Chandler wrote: > The command described here works fine when I go one way: replace myvar > = myvar[_n-1] if myvar >= . > > However, when I try to replace in the other direction replace myvar = > myvar[_n+1] if myvar >= ., it doesn't work and I have to repeat the > command for each time I want it to copy... Does anyone have any > suggestions? > > I've read the below, but it doesn't quite make sense. > > http://www.stata.com/support/faqs/data/missing.html > * * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Replacing missing values only works one way?***From:*Dana Chandler <dchandler@gmail.com>

- Prev by Date:
**Re: st: heteroskedasticity test in panel data** - Next by Date:
**Re: st: Dropping observations and creating a balanced panel** - Previous by thread:
**st: Replacing missing values only works one way?** - Next by thread:
**Re: st: Replacing missing values only works one way?** - Index(es):