Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: st: generating lag variable in a Panel Dataset


From   "Clifton Chow" <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index