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

From |
"tony fong" <tbfong@hotmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: assistance writing a loop to create a panel dataset |

Date |
Sun, 13 Nov 2005 10:11:24 -0800 |

Hi everyone,

I have a dataset that I need to restructure, and I'm having trouble writing the code that would accomplish this for me (programming is new territory for me). If someone could help me out on this, it'd be extremely appreciated!

My data is currently set up as such:

+------------------------------------------------------+

id sch1 sch2 start1 end1 start2 end2

------------------------------------------------------

1. 1 73 . 199308 200000 . .

2. 2 46 . 199307 199506 . .

3. 3 12 16 199308 199505 199508 199606

4. 4 94 58 199408 199412 199501 199606

5. 5 24 . 199608 199706 . .

------------------------------------------------------

6. 6 84 43 199308 199605 199608 199611

7. 7 16 . 199508 200000 . .

8. 8 59 87 199309 199406 199609 200000

+------------------------------------------------------+

where sch1 and sch2 represent the school ID that the teacher was teaching at for the respective teaching spells 1 and 2, and start1-end2 represent the start and end dates of spells 1 and 2,

where the first four digits is the year and the last two digits is the month of that year (actually my data has five possible start and end date spells, but it got too messy in pasting the info above). If the end date is 200000, then the teacher remained at that school until the data was right-censored in 1998. I've cleaned the data so that all of the spells are in order and none of them overlap (although there are gaps of time between some teaching spells). What I'm trying to do is create a panel data set in long format, with one observation for each year from 1992 until 1997 for every individual. It would give the school that the individual taught at for each year (where for the year 1995, for instance, it would correspond to the school number that the teacher taught at for any of the months from 199507 through 199606, inclusive), or it'd be a missing value if the teacher did not teach during that year since some teachers started later and many teachers quit after only a year or two. I've tried to create a set of loops that loops through each consecutive non-missing spell to fill in the variables school92-school97 (which represent the school taught at for each year) based on the start and end dates of each spell, but I've been unable to do it. Also, some teachers teach at one school for half the year and another school for the rest of the year -- in this case the first school should count for that particular year. If anyone can help me out with the code that would accomplish this task it would be very much appreciated.

Thanks!

Tony

*

* 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/

- Prev by Date:
**RE: st: math fonts/symbols** - Next by Date:
**Rép. : RE: st: Kwallis in a loop [now p-value of the Kwallis]** - Previous by thread:
**[no subject]** - Next by thread:
**Rép. : RE: st: Kwallis in a loop [now p-value of the Kwallis]** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |