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 at the end of May, and its replacement, statalist.org is already up and running.


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

RE: st: Fill


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Fill
Date   Fri, 26 Feb 2010 16:50:04 -0000

If that's the answer, there is supporting discussion at 

How can I replace missing values with previous or following nonmissing values or within sequences?
http://www.stata.com/support/faqs/data/missing.html

Nick 
n.j.cox@durham.ac.uk 

Scott Merryman

Like this?

clear
input id decile	year
1	1	1999
2	6 	1999
4	9	1999
4	.	2001
2	.	2001
1	.	2001
2	.	2002
end

bys id (dec): replace dec = dec[_n-1] if dec ==.
sort year dec
l

On Fri, Feb 26, 2010 at 6:45 AM, Tiago Fonseca
<tiago.p.fonseca@gmail.com> wrote:

> How can I solve this problem. I have a set of data like these:
> Industry code
>        Decile
>        Year
> 1
>        1
>        1999
> 2
>        6
>        1999
> 4
>        9
>        1999
> 4
>        .
>        2001
> 2
>        .
>        2001
> 1
>        .
>        2001
> 2
>        .
>        2002
>
>
> I have a industry code, the decile of the base year (1999) and I want to
> fill the decile in the remaining years. The solution will be like:
> 9
> 6
> 1
> 6
>
> How to solve it for a large set of data?

*
*   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