[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: Re: assistance writing a loop to create a panel dataset |

Date |
Sun, 13 Nov 2005 12:57:37 -0800 |

Hi all,

Nick mentioned that I should show the code I've been working on to change my dataset into panel data, but I haven't been able to put anything together worth showing as I'm new to writing code (so I'm still at square one). Below I also try to repost the example of what my data currrently looks like, as it was kind of tough to read in the last email. If anyone could assist me it'd be greatly appreciated.

Thanks!

id sch1 sch2 start1 end1 start2 end2

1 73 . 199308 200000 . .

2 46 . 199307 199506 . .

3 12 16 199308 199505 199508 199606

4 94 58 199408 199412 199501 199606

5 24 . 199608 199706 . .

6 84 43 199308 199605 199608 199611

7 16 . 199508 200000 . .

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:
**st: RE: Re: Lots of date vars, more FU qx for Eric Wruck** - Next by Date:
**st: Questions on weights on regressions** - Previous by thread:
**st: RE: assistance writing a loop to create a panel dataset** - Next by thread:
**RE: st: Re: assistance writing a loop to create a panel dataset** - Index(es):

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