Bookmark and Share

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, is already up and running.

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

Re: st: Converting monthly values to quarterly averages

From   Nick Cox <>
Subject   Re: st: Converting monthly values to quarterly averages
Date   Wed, 20 Feb 2013 18:05:59 +0000

Another way to map from months to quarters is using -qofd(dofm())-.


On Wed, Feb 20, 2013 at 5:34 PM, Ryan Stevens <> wrote:

> More information would be needed regarding what format your months are
> in, but assuming that you've changed Jan-Dec to 1-12, you could use
> the following:
> gen quarter = .
> replace quarter = 1 if inrange(month,1,3)
> replace quarter = 2 if inrange(month,4,6)
> replace quarter = 3 if inrange(month,7,9)
> replace quarter = 4 if inrange(month,10,12)
> collapse (mean) wpivalue, by(Industry year quarter)
> If there are other things in your dataset you are looking to keep,
> you'll have to merge the result of this collapse back to them.

 On Wed, Feb 20, 2013 at 12:12 PM, Chari, Anusha <> wrote:

>> I have data at a monthly frequency by industry across years and would like to create quarterly averages by industry and year. I tried the tscollap command after specifying that the data was a panel and get an error that time-series operators not allowed. Please advise.
>> My data are in the following format:
>> Industry month year wpivalue
>>  I would like to convert them to:
>> Industry quarter year wpiqtraverage

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index