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: Tracking Replacements Made to Variables
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Tracking Replacements Made to Variables
Date
Tue, 1 Feb 2011 11:02:13 +0000
On a different tack: note that what you did is just linear
interpolation. See -help ipolate-.
What you did presupposes that times are regularly spaced (probably not
an issue in your case) and it will only work to fill in gaps of length
1 (perhaps deliberately). -ipolate- will handle both issues. It still
leaves open the question of whether linear interpolation is the best
way to interpolate. Other interpolation commands include -cipolate-
and -csipolate- (SSC).
Nick
On Mon, Jan 31, 2011 at 9:13 PM, Christopher Lanoue <[email protected]> wrote:
> My problem is that I am trying to keep track of changes that I make to
> my data [....] For instance if I have data such as:
>
> yr var1
> 1961 15
> 1962 .
> 1963 20
> 1964 .
> 1965 30
>
> and I want to take the average of the two data points to fill in the
> missing values.
>
> I run replace var1 = (var1[_n-1]+var1[_n+1])/2 if var1 == . to
> accomplish this task
*
* 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/