Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: st: generating lag variable in a Panel Dataset


From   "Clifton Chow" <clifton_chow@post.harvard.edu>
To   statalist@hsphsun2.harvard.edu
Subject   st: st: generating lag variable in a Panel Dataset
Date   Thu, 02 Feb 2012 18:20:36 -0500

I have a panel dataset on employment in which individuals progress between jobs, each with a job start and end date as follows:

ID     JobNumber    Start          End
1              1           8/1/10      12/30/10
1              2           1/20/11      3/10/11
1              3           5/25/11      12/20/11
2              1           11/1/10       3/20/11
2              2            4/1/11        9/30/11 

I am trying to calculate the duration of Unemployment by lagging job end date so that unemployment duration is the date difference between the end of the previous job and the start of the following job.  However, I need to carefully generate the lag variable by ID.  Is there a way I could do this easily within STATA?  For example, something like 

gen unempdur=Start - lag(End) if ID = lag(ID)   ?

Thanks for your replies.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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