Good morning,
I'm currently using Eviews 7.
I've got a quarterly time series, say varX, that I want to transform in the following way :
if first quarter then varX_C=varX
if second quarter then varX_C = mean of qarter 1 and 2
if third quarter then varX_C = mean of qarter 1, 2 and 3
if fourth quarter then varX_C = mean of qarter 1, 2, 3 and 4
Here is what I'v came up with :
series varX_C = @recode( @quarter=1, varX, @recode( @quarter=2,( varX + varX(-1) )/2, _
@recode( @quarter=3,( varX + varX(-1) + varX(-2) )/3, _
( varX + varX(-1) + varX(-2) + varX(-3) )/4) )
)
Even though this formula works fine, I was wondering if there is a more elegant way of computing varX_C ?
Thanks!
series transformation using @recode
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: series transformation using @recode
There may be a better way, but this should work if your workfile/sample starts in the first quarter.
If we had a year-to-date function (we've added it to the list) this would be easier.
Code: Select all
series anncumulative = @recode(@quarter=1, y, anncumulative(-1)+y(-1))
series ystar = @meansby(anncumulative, @quarter)Re: series transformation using @recode
I like the code you posted.
Many thanks Glenn!
Many thanks Glenn!
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: series transformation using @recode
It would be good if I posted correct code.
The last element on the first line should be Y, not Y(-1).
Code: Select all
series anncumulative = @recode(@quarter=1, y, anncumulative(-1)+y)
Who is online
Users browsing this forum: No registered users and 1 guest
