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]

st: Re: spells of missing values completely in between


From   Abhimanyu Arora <abhimanyu.arora1987@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Re: spells of missing values completely in between
Date   Sat, 7 Apr 2012 13:01:05 +0200

Somehow I feel the step in which the temp is generated can be omitted
by a clever use of the -cond- option.

On Sat, Apr 7, 2012 at 12:57 PM, Abhimanyu Arora
<abhimanyu.arora1987@gmail.com> wrote:
> Dear statalist
> I was wondering if there is a more elegant solution to one below
> involving SSC's tsspell by Nick Cox
> . which tsspell
> c:\ado\plus\t\tsspell.ado
> *! 2.0.0 NJC 13 August 2002
>
> The aim is to create an indicator for spells of missing values
> completely in between a series (excluding those at the beginning or
> the end). (A part in the process of intrapolating a time series,
> basically)
>
> I used the following set of commands.
>
>
> clear
> set obs 12
> gen var1=_n
> tsset var1
> input var2
> .
> .
> .
> 56
> .
> .
> .
> 95
> .
> 20
> .
> end
> tsspell var2
> egen temp=max( _spell)
> gen ind=(var2==. & _spell==1)|(var2==. & temp==_spell)| (var2!=.)
>
> Cheers
> Abhimanyu
*
*   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