Bookmark and Share

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]

st: spells of missing values completely in between


From   Abhimanyu Arora <[email protected]>
To   [email protected]
Subject   st: spells of missing values completely in between
Date   Sat, 7 Apr 2012 12:57:39 +0200

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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index