Splits records of time-span data
spellsplit [clist], spell(start end) [by(varlist)]
where clist is [(stat)] varlist [ [(stat) ... ]
and stat is either mean or sum
Description
nojoin breaks overlapping spells in disjoint adjacent spells.
clist with statistics instructs how to treat variables when spells overlap; to sum them or take an average.
spellsplit x1 x2, spell(date0 date1) by(id)
is equivalent to
spellsplit (mean) x1 x2, spell(date0 date1) by(id)
As an example, if two overlapping spells refer to a job and the variable is hours worked one would like to sum (to get the total hours worker), whereas if the variable is the worker's age one would like to take the average (which will just be the worker's age).
spellsplit Does the following
Suppose you have this
. l d0 d1 x 1. 1Jan99 6Jan99 1 2. 2Jan99 7Jan99 .2 3. 4Jan99 8Jan99 .5 4. 4Jan99 10Jan99 .1 5. 16Jan99 21Jan99 .7
. spellsplit x, spell(d0 d1)
. l d0 d1 x _count 1. 01Jan1999 02Jan1999 1 1 2. 02Jan1999 04Jan1999 .6 2 3. 04Jan1999 06Jan1999 .45 4 4. 06Jan1999 07Jan1999 .2666667 3 5. 07Jan1999 08Jan1999 .3 2 6. 08Jan1999 10Jan1999 .1 1 7. 16Jan1999 21Jan1999 .7 1
where _count is the number of intercepting spells and x is averaged. Author
E. Leuven, Department of Economics, University of Amsterdam. If you observe any