Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: How to aggregate daily data in Stata |

Date |
Sat, 15 Dec 2012 22:14:48 +0000 |

. help collapse Nick

Have a question that should be easy to figure out for the experts,but Ican't wrap my mind around it conceptually.I have daily stock market data for 28 countries over a 20-odd yearperiod.Some countries have 6 years of data, some have 20 years, etc.,depending onwhen they started their stock markets. I want to calculate avolatilitymetric by using the sum of squares of daily changes for each month(that is,aggregate the daily squared changes for each month). Given that thepaneldata has different time lengths and there are different monthlyperiods(i.e. some months have 30 days, some countries have holidays in themonth sothere's no data), how can I use stata to sum the squares of the daily changes by month? For example, I have Belarus March-1-05 1.37 Belarus March-2-05 0.69 . . . Belarus March 31-05 17.33And I want to generate one variable per country per month that isthe sum ofthese numbers, so that I have Belarus Mar-05 37.20 Belarus Apr-05 18.99 Etc.Is there an easy "by x:" command that will let me do it? Or someiterationthat will allow for this? The problem I see is that I need to sum the data first by day over a specific month, for each month, for each country, on a dataset that is severely unbalanced.

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

**Follow-Ups**:**RE: st: How to aggregate daily data in Stata***From:*"Christopher A. Hartwell" <christopher.hartwell@msn.com>

**References**:**st: How to aggregate daily data in Stata***From:*"Christopher A. Hartwell" <christopher.hartwell@msn.com>

- Prev by Date:
**st: How to aggregate daily data in Stata** - Next by Date:
**st: how to implement a dictionary (aka map, look-up table)** - Previous by thread:
**st: How to aggregate daily data in Stata** - Next by thread:
**RE: st: How to aggregate daily data in Stata** - Index(es):