| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: RE: st: From spell to person-month file
This is the merge-Meisters versus the by-pilots all
over again.
That is, some people set this kind of thing up as a dance
of the files, with elaborate pas de deux fit for Fonteyn
and Nureyev in their prime;
others prefer to do it less balletically in place.
I'm a by-pilot. To get from this
Persnr n_job beg end sect
1 1 1 3 1
1 2 4 7 3
1 3 8 10 2
to this
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
I would go
gen length = end - beg + 1
expand length
bysort persnr (n_job) : gen month = _n
drop length
Nick
[email protected]
Ronnie Babigumira
=================
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
Anna Manzoni
============
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
*
* 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/