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: Converting monthly values to quarterly averages


From   Nick Cox <[email protected]>
To   [email protected]
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())-.

Nick

On Wed, Feb 20, 2013 at 5:34 PM, Ryan Stevens <[email protected]> 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 <[email protected]> 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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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