Statalist The Stata Listserver


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

Re: st: From spell to person-month file


From   Ronnie Babigumira <rb.glists@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: From spell to person-month file
Date   Wed, 29 Mar 2006 11:10:44 +0200

Now we are talking (the illustration helps). Another shot (the number of lines will probably be cut in half). Assume you have two files, person and spell

use person, clear
egen beg = min(month), by(Persnr n_job)
egen end = max(month), by(Persnr n_job)
sort Persnr n_job beg end
save tempa, replace

use spell, clear
sort Persnr n_job beg end
merge Persnr n_job beg end using tempa
drop beg end _merge
move month n_job
sort Persnr month
list


A. Manzoni wrote:

No, I have added to the spell file information related to the
characteristics of the job (I could add them only to the spell file, and not
directly to the person month), so now, in my spell file I have a variable
saying for example the sector in which someone was employed. I now want to go back to the person month file keeping also this info on the
sector, so I have for every month in which a spell was hold, the sector
variable.
So illustrating>
The first original person month file was

Persnr month n_job
1 1 1
1 2 1
1 3 1
1 4 2
1 5 2
1 6 2
1 7 2
1 8 3
1 9 3
1 10 3

The spell file I have generated is

Persnr n_job beg end
1 1 1 3
1 2 4 7
1 3 8 10


Thenn I have added the sector variable, so it looks like
Persnr n_job beg end sect
1 1 1 3 1
1 2 4 7 3
1 3 8 10 2

And now I want a person month likethis:


Persnr month n_job sect
1 1 1 1
1 2 1 1
1 3 1 1
1 4 2 3
1 5 2 3
1 6 2 3
1 7 2 3
1 8 3 2
1 9 3 2
1 10 3 2


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/

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