Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: How to construct a duration variable?


From   "Scott Merryman" <smerryman@kc.rr.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: How to construct a duration variable?
Date   Thu, 6 Apr 2006 15:26:03 -0500

A slight modification is necessary:

tsset hhid per
encode b, gen(b2)
tsspell b2
bysort hhid _spell: replace _seq = _seq[_N]
rename _seq duration
drop _* b2


-tsspell- creates _spell by:
= by hhid: gen long _spell = sum((brand != L.brand) | (_n == 1) & __000001)

while -spell- uses explicit subscripting.

Scott

> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-
> statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
> Sent: Thursday, April 06, 2006 3:00 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: RE: st: RE: How to construct a duration variable?
> 
> I think Richard disagrees slightly, but -spell-, whiIe
> it is still there on SSC for users of Stata 6, has not
> been touched by either of us since 2000.
> 
> I'd recommend instead -tsspell-,
> which is the successor maintained by me (with
> ack'ts to Richard for his contributions). -tsspell-
> is slightly more restrictive in insisting on -tsset-,
> but in practice that limitation is no limitation.
> It too is present on SSC.
> 
> Nick
> n.j.cox@durham.ac.uk
> 


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index