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: Thread-Index: AQHNGEBCIuB42jRH6ke3cai302EPyw==


From   Jorge Eduardo Pérez Pérez <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Thread-Index: AQHNGEBCIuB42jRH6ke3cai302EPyw==
Date   Wed, 11 Apr 2012 20:26:51 -0400

sysuse sp500, clear
gen week=wofd(date)
format week %tw
* Day of week. 0=Sunday
gen day=dow(date)
* Drop some wednesdays and tuesdays for the sake of the example
drop if day==3 in 1/75
drop if day==2 in 1/25
* Keep Wednesday, Tuesday and Thursday.
keep if day==3 | day==2 | day==4
* Create ordering variable: Wednesday, Tuesday, Thursday
gen order=.
replace order=1 if day==3
replace order=2 if day==2
replace order=3 if day==4
sort week order
collapse (firstnm) close day, by(week)

_______________________
Jorge Eduardo Pérez Pérez



On Wed, Apr 11, 2012 at 8:07 PM, Mark Bailie <[email protected]> wrote:
> Hi,
>
> I have daily data of stock prices dating back to the 1950s and I would like to collapse the dataset into weekly data.
>
> I want the weekly data to be formed from the stock price on every Wednesday.
>
> Some weeks do not have a Wednesday, due to the stock markets closed that day.  In these cases I want to use the value from Tuesday for that week.
>
> Bascially:
>
> COLLAPSE DAILY TO WEEKLY ON EACH WEDNESDAY -- ALTHOUGH IF THERE IS NO WEDNESDAY THAT WEEK TAKE THE TUESDAY VALUE  --   IF NO TUESDAY, TAKE THE THURSDAY
>
> Can this be done?
>
> Kind regards,
>
> Mark
> *
> *   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index