Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: How do I fill in missing values using last-observation-carried-fo rward (LOCF) in stata


From   "Steichen" <[email protected]>
To   <[email protected]>
Subject   st: Re: How do I fill in missing values using last-observation-carried-fo rward (LOCF) in stata
Date   Mon, 12 Jan 2004 23:02:03 -0500

Assuming the data is sorted by date, use

  replace dummy=dummy[_n-1] if dummy==.


----- Original Message ----- 
From: <[email protected]>
To: <[email protected]>
Sent: Monday, January 12, 2004 10:03 PM
Subject: st: How do I fill in missing values using
last-observation-carried-fo rward (LOCF) in stata


> Is there an easy way of implementing the following task in STATA? (It
> sounds a very easy task, but it goes beyond my limited knowledge of
STATA.)
>
> Say, I have a data series with two variables: date, dummy
>
> date      dummy
> 1/1/03      1
> 1/2/03      .
> 1/3/03      3
> 1/4/03      .
> 1/5/03      .
> 1/7/03      2
> 1/8/03      .
> 1/9/03      .
> 1/10/03    .
> 1/11/03    4
> 1/12/03    .
> 1/13/03    .
> .......
>
> I just want to fill the missing value, using the previous value until it
> changes (or the last-observation-carried-forward method), ie, to get
>
> date      dummy
> 1/1/03      1
> 1/2/03      1
> 1/3/03      3
> 1/4/03      3
> 1/5/03      3
> 1/7/03      2
> 1/8/03      2
> 1/9/03      2
> 1/10/03    2
> 1/11/03    4
> 1/12/03    4
> 1/13/03    4
> .......
>
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index