Statalist The Stata Listserver


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

st: RE: date data manipulation


From   "Rajesh Tharyan" <R.Tharyan@exeter.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: date data manipulation
Date   Sun, 5 Feb 2006 13:24:19 -0000

Hi,

I had asked a similar question earlier on. My solution would be

Generate a variable using _n so the missing dates don't matter.

gen a=_n

And then 

gen Trading_ID = floor(a/3)

regards
rajesh


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of
bta78@mail.eco.utexas.edu
Sent: 03 March 2006 03:01
To: statalist@hsphsun2.harvard.edu
Subject: st: date data manipulation

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/

*
*   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–2020 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index