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: creation of a new variable using a variable condition
From
Riccardo Valboni <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: creation of a new variable using a variable condition
Date
Fri, 21 Feb 2014 15:04:54 +0000
Dear statalist,
I am trying to do something that it's probably basic but I cannot get to the bottom of it.
I have a typical unbalanced panel dataset. Some of my observations happen to have an event at a certain point in time (coded 1 in the 'event' column). For them I would like to generate a new variable (newvar) that takes value 1 from the year of the first event onwards. The year of the first event obviously changes from case to case. (see the example below)
id year event newvar
a 2001 0 0
a 2002 0 0
a 2003 1 1
a 2004 1 1
b 2005 0 0
b 2006 1 1
b 2007 0 1
b 2008 0 1
b 2009 0 1
...
I imagine that the command to do this starts with: by id... but I wouldn't know how continue that. Any suggestions?
Thank you!
Riccardo
Disclaimer
________________________________
De informatie verzonden in dit e-mail bericht is vertrouwelijk en is uitsluitend bestemd voor de geadresseerde van dit bericht. Lees verder: www.eur.nl/email-disclaimer <http://www.eur.nl/email-disclaimer>
The information in this e-mail message is confidential and may be legally privileged. Read more: www.eur.nl/english/email-disclaimer<http://www.eur.nl/english/email-disclaimer>
________________________________
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/