Page 1 of 1

Monthly data by quarter

Posted: Tue Apr 11, 2017 6:52 am
by miorinnovo
Hi

I would like to use monthly data in a quarterly page. For quarters where all 3 months are available the simple average across monthly values option is fine, but I don't want to waste any available months past the last full quarter.

How can I use monthly series in a quarterly page so that the months are average except when there are only 1 or 2 months in the last quarter, in which case I would want to repeat the last available month for the empty months in that quarter and only then average the 3 months.

Thanks!

Re: Monthly data by quarter

Posted: Tue Apr 11, 2017 8:59 am
by EViews Gareth
I think the easiest way would be on the monthly page to create a new series that is equal to the original series, but fills in the missing months with the previous month's value.
If it is always only the last month of a quarter that is missing something as simple as:

Code: Select all

series x = @recode(y=na, x(-1), y)
would do the trick (assuming the very first observations is not an NA).

Re: Monthly data by quarter

Posted: Tue Apr 11, 2017 11:06 am
by EViews Matt
If your monthly data doesn't fall on quarter boundaries, or you don't want to extend it so that Gareth's solution could be applied, you could also explicitly "clean up" the last observation of the quarterly data. For example, for a fictitious series x on two pages "Monthly" and "Quarterly":

Code: Select all

pageselect Monthly if @mod(@datepart(@dateval(x.@last), "mm"), 3) = 2 then smpl @last-1 @last !avg = (@first(x) + 2 * @last(x)) / 3 pageselect Quarterly smpl @last @last x = !avg endif

Re: Monthly data by quarter

Posted: Tue Apr 11, 2017 1:33 pm
by miorinnovo
series x = @recode(y=na, x(-1), y)
I think I did this wrong because only 1 NA gets filled or the whole series is NA. So x is the old series and y is the new series?

Re: Monthly data by quarter

Posted: Tue Apr 11, 2017 3:41 pm
by EViews Matt
The reverse, x is the new series and y is the old series.

Re: Monthly data by quarter

Posted: Wed Apr 12, 2017 10:24 am
by miorinnovo
ah, of course. thanks!