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]

Re: st: generating event windows from event dates


From   Bülent Köksal <bkoksal@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: generating event windows from event dates
Date   Mon, 21 May 2012 17:00:30 +0300

Great, thanks.

A slight modification of your code for other windows:

gen eventwindow=0
forvalues i=-10(1)10 {
replace eventwindow=1 if eventdate[_n+`i']==1
}

bülent

On Mon, May 21, 2012 at 3:17 PM, Fernando Rios Avila <f.rios.a@gmail.com> wrote:
> Hi Bülent Köksal
> what about this 6 line code:
> gen eventwindow=0
> replace eventwindow=1 if evendate[n-2]==1
> replace eventwindow=1 if evendate[n-1]==1
> replace eventwindow=1 if evendate[n]==1
> replace eventwindow=1 if evendate[n+1]==1
> replace eventwindow=1 if evendate[n+2]==1
> Fernando
>
> On Mon, May 21, 2012 at 7:55 AM, Bülent Köksal <bkoksal@gmail.com> wrote:
>> Dear Stata Users
>>
>> I have a dummy variable that equals one for certain event dates. How
>> can I generate a new indicator variable that is equal to one for event
>> windows like (-2,2)?
>>
>> For example,
>>
>> I have t and eventdate below and would like to generate eventwindow.
>> Thanks in advance for any help.
>>
>>
>> t       eventdate       eventwindow
>> 1       0       0
>> 2       0       0
>> 3       0       1
>> 4       0       1
>> 5       1       1
>> 6       0       1
>> 7       0       1
>> 8       0       0
>> 9       0       0
>> .
>> .
>> .
>> 16      0       0
>> 17      0       0
>> 18      0       1
>> 19      0       1
>> 20      1       1
>> 21      0       1
>> 22      0       1
>> 23      0       0
>> 24      0       0
>>
>>
>>
>> --
>> Bülent Köksal
>>
>> *
>> *   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/
>
> *
> *   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/



-- 
Bülent Köksal

*
*   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