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: Identifying and recording the first occurrence of an event by actor given category


From   Erik Aadland <erikaadland@hotmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Identifying and recording the first occurrence of an event by actor given category
Date   Fri, 7 Sep 2012 09:07:45 +0000

Dear Statalist.
I have an unbalanced panel dataset.
This is the structure:
actor_id    year    category_id    event    
1           2000    1              .
1           2000    2              1
1           2001    2              1
2           2003    3              .
2           2003    2              1
2           2004    2              .

I want to generate a variable -first_occurrence- that identifies and records for each actor_id the first time the actor experienced event = 1 if the category = e.g. 2. I would like this -first occurrence- variable to capture the value of -year- at the time of first event occurrence. Some actors never experience event = 1.
For instance, if I track first occurrence by category_id = 2, this is what I look for:
actor_id    year    category_id    event    first_occurrence   
1           2000    1              .        2000
1           2000    2              1        2000
1           2001    2              1        2000
2           2003    3              .        2003
2           2003    2              1        2003
2           2004    2              .        2003

Any input or suggestions on this problem would be greatly appreciated.
Kind regards,
Erik. 		 	   		  
*
*   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