Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Creating new variable from existing observations


From   Nick Cox <[email protected]>
To   [email protected]
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 <[email protected]> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index