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]

Re: st: Event time creation


From   Nick Cox <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Event time creation
Date   Fri, 19 Apr 2013 09:15:33 +0100

egen benchmark  = total(time / (event == "Yes"))
gen eventtime = time - benchmark
expand 2

There could be all sorts of complications you have not told us about.

For example: These are really panel data.

egen benchmark  = total(time / (event == "Yes"))  , by(id)

For example: The -event- variable is really 0-1 and we are just seeing
value labels.

egen benchmark  = total(time / (event == 1))  , by(id)

See also

http://stackoverflow.com/questions/15298526/determine-time-period-since-event-up-to-n-leads-lags

http://www.stata-journal.com/article.html?article=dm0055

Nick
njcoxstata@gmail.com


On 19 April 2013 03:00, Auh, Jun Kyung <jauh14@gsb.columbia.edu> wrote:

> I am wondering how I can create the event time variable. For example I want to create something like this:
>
> Time            Event   EventTime
> 2000m1          No      -2
> 2000m2          No      -1
> 2000m3          Yes     0
> 2000m4          No      1
> 2000m5          No      2
>
> Furthermore, what I actually want to create is the following:
>
> Time         ID Event   EventTime
> 2000m1          No      -2
> 2000m1          No      -2
> 2000m2          No      -1
> 2000m2          No      -1
> 2000m3          Yes     0
> 2000m3          Yes     0
> 2000m4          No      1
> 2000m4          No      1
> 2000m5          No      2
> 2000m5          No      2
>
*
*   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/


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