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: copying last reported value
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: copying last reported value
Date
Sat, 19 Feb 2011 19:05:16 +0000
Also note that this is an FAQ.
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
Nick
On Sat, Feb 19, 2011 at 6:23 PM, Christopher Baum <[email protected]> wrote:
. g var4 = .
> (20 missing values generated)
>
> . bys var2 (var1): replace var4 = cond(mi(var3), var4[_n-1], var3)
> (17 real changes made)
>
> . l
>
> +---------------------------+
> | var1 var2 var3 var4 |
> |---------------------------|
> 1. | 1 1 . . |
> 2. | 2 1 .2 .2 |
> 3. | 3 1 . .2 |
> 4. | 4 1 . .2 |
> 5. | 5 1 . .2 |
> |---------------------------|
> 6. | 6 1 . .2 |
> 7. | 7 1 . .2 |
> 8. | 8 1 .3 .3 |
> 9. | 9 1 . .3 |
> 10. | 10 1 . .3 |
> |---------------------------|
> 11. | 1 2 . . |
> 12. | 2 2 . . |
> 13. | 3 2 .1 .1 |
> 14. | 4 2 . .1 |
> 15. | 5 2 . .1 |
> |---------------------------|
> 16. | 6 2 . .1 |
> 17. | 7 2 .5 .5 |
> 18. | 8 2 . .5 |
> 19. | 9 2 . .5 |
> 20. | 10 2 . .5 |
> +---------------------------+
>
*
* 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/