Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: date data manipulation


From   [email protected]
To   [email protected]
Subject   st: date data manipulation
Date   Thu, 02 Mar 2006 21:00:32 -0600

Hi all -
This may seem like a silly question, but I have data that look like this

Date          Stock Price   Event_dummy
12apr2002         43             0
13apr2002         44             0
16apr2002         45             0
17apr2002         49             0
18apr2002         46             0
18apr2002         48             0
..
20sep2003         65             1
21sep2003         67             1
24sep2003         70             1
..
09feb2004         60             0
10feb2004         61             0
11feb2004         59             0


what I want is to split up the data into 3-day chunks (making sure that one of
those 3 day chunks is the event period), so I can collapse them by mean stock
price.  As you can see, I'm just using trading days, which means there are gaps
in the dates for weekends/holidays/etc.  I don't care about days at the
beginning or end of the data (in case they aren't perfectly divisible by 3).
Here's what I want:


Date          Stock Price   Event_dummy   Trading_ID
12apr2002         43             0            1
13apr2002         44             0            1
16apr2002         45             0            1
17apr2002         49             0            2
18apr2002         46             0            2
18apr2002         48             0            2
..
20sep2003         65             1            45
21sep2003         67             1            45
24sep2003         70             1            45
..
09feb2004         60             0            60
10feb2004         61             0            60
11feb2004         59             0            60


Is there a quick way to do this?

Thanks,
Ben

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index