Statalist The Stata Listserver


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

Re: st: Job spell sortid


From   "Ada Ma" <[email protected]>
To   [email protected]
Subject   Re: st: Job spell sortid
Date   Thu, 23 Mar 2006 16:48:00 +0000

sort pid jobchange month
by pid jobchange: gen n_job=_n if jobchange==1
sort pid month
replace n_job=n_job[_n-1] if n_job==.




On 3/23/06, A. Manzoni <[email protected]> wrote:
> I have a file with the variables persnr, month, empl(dummy var for
> employed/non employed), n_empl (indicating the order number of employment
> spells)
> jobchange(indicating the month in which there is a job to job change, which
> is not recorded as employment spell, because an employment spell is defined
> when there is a non employment spell in between two jobs, so in case one go
> from a job to another job without going out of employment, I have only one
> employment spell, but I want to have 2 job spells)
>
> I want to create a n_job variable (see below), indicating the order number
> of job spells. How can I do?
>
>
>
> pid  month              empl    n_empl  jobchange
> n_job
> 1       1               1               1                       .
> 1
> 1       2               1               1                       .
> 1
> 1       3               1               1                       1
> 2
> 1       4               1               1                       .
> 2
> 1       5               1               1                       .
> 2
> 1       6               1               1                       .
> 2
> 1       7               1               1                       1
> 3
> 1       8               1               1                       .
> 3
> 1       9               1               1                       .
> 3
> 1       10              1               1                       1
> 4
> 1       11              1               1                       .
> 4
> 1       12              0               .                       .
> .
> 1       13              0               .                       .
> .
> 1       14              1               2                       .
> 5
> 1       15              1               2                       .
> 5
> 1       16              1               2                       1
> 6
> 1       17              1               2                       .
> 6
>
>
> Thanks,
> Anna
>
> *
> *   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/
>


--
Ada Ma
Research Fellow
Health Economics Research Unit
University of Aberdeen, UK.
http://www.abdn.ac.uk/heru/
Tel: +44 (0) 1224 553863
Fax: +44 (0) 1224 550926

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