Monthly data by quarter

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

Monthly data by quarter

Postby miorinnovo » Tue Apr 11, 2017 6:52 am

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!

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13305
Joined: Tue Sep 16, 2008 5:38 pm

Re: Monthly data by quarter

Postby EViews Gareth » Tue Apr 11, 2017 8:59 am

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).
Follow us on Twitter @IHSEViews

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: Monthly data by quarter

Postby EViews Matt » Tue Apr 11, 2017 11:06 am

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
Last edited by EViews Matt on Wed Apr 12, 2017 8:48 am, edited 1 time in total.

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

Re: Monthly data by quarter

Postby miorinnovo » Tue Apr 11, 2017 1:33 pm

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?

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: Monthly data by quarter

Postby EViews Matt » Tue Apr 11, 2017 3:41 pm

The reverse, x is the new series and y is the old series.

miorinnovo
Posts: 199
Joined: Sun Mar 01, 2015 5:01 pm

Re: Monthly data by quarter

Postby miorinnovo » Wed Apr 12, 2017 10:24 am

ah, of course. thanks!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 21 guests