Bookmark and Share

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]

Re: st: Creating new variable from existing observations


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Creating new variable from existing observations
Date   Sat, 9 Jun 2012 18:51:34 +0100

This is an FAQ. See

FAQ     . . . . . . . . . . . . . . . . . . . . . . . Replacing missing values
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        2/03    How can I replace missing values with previous or
                following nonmissing values?
                http://www.stata.com/support/faqs/data/missing.html

For what you seem to want, you would need to reverse time.


On Sat, Jun 9, 2012 at 6:47 PM, Suryadipta Roy <sroy2138@gmail.com> wrote:

> I actually had another question relating to replacing missing
> observations for panel data. My original dataset has been sorted by
> exporter, importer, and year. I am trying the following to replace
> missing observations for a variable for both importer and exporter by
> a following value for one/more years:
>
> by importer exporter (year), sort: replace myvar = myvar[_n+1] if myvar >= .
>
> However, this only replaces the value for one previous year and leaves
> the rest unchanged. Can anyone let me know how to fix this problem and
> replace the missing value for all previous years for all exporters and
> importers?
>
*
*   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/


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