Statalist The Stata Listserver


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

st: Isolating a single spell


From   "sara khan" <sarakhanum84@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Isolating a single spell
Date   Wed, 28 Mar 2007 12:15:40 +0100

Dear Statlisters

I was wondering if you help me in isolating a single spell from a
multiple spell series.

I have data on employment status and I wish to extract the longest
employment spell (indexed by longspl) and also whether the person
exited employment in the next wave ie exit==1. In the example below,
for person 1, I wish to keep waves 4-7 as the longest spell ended in
an exit. For person 2, I wish to keep waves 2-12 even though the spell
is censored (no exit took place).

I tried by pid: keep if longspl==1 & exit[_n+1]>=0 but this doesn't
work. I would be grateful for suggestions.

Many thanks
Sara


+--------------------------------------+
    id   wave   empstat   exit   longspl
--------------------------------------
1.   1      1   not emp        0         0
2.   1      2       emp          0         0
3.   1      3   not emp         1         0
4.   1      4       emp          0         1
5.   1      5       emp          0         1
6.   1      6       emp          0         1
7.   1      7   not  emp       1         0
8.   1      8   not  emp       0         0
9.   1      9   not emp        0         0
10.   1     10   not emp      0         0
11.   1     11   not emp      0         0
12.   1     12   not emp      0         0
--------------------------------------
13.   2      1   not emp      0         0
14.   2      2       emp      0         1
15.   2      3       emp      0         1
16.   2      4       emp      0         1
17.   2      5       emp      0         1
18.   2      6       emp      0         1
19.   2      7       emp      0         1
20.   2      8       emp      0         1
21.   2      9       emp      0         1
22.   2     10       emp      0         1
23.   2     11       emp      0         1
24.   2     12       emp      0         1
+--------------------------------------+
*
*   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