Page 1 of 1

Scalar of average of last 12 months

Posted: Wed Jul 11, 2018 9:35 am
by BCNAV
I have a work file from 2011M01 to 2018M12

The last date I have data for is 2018M06.

I need a away to automatically calculate the average of a variable over the last 12 months and dump it into a scalar.

I had tried smpl @last-12 @last but that does not work, as it does to the end of the workfile that has no data in it (data only does to june 2018).

Is there a way to get the last non-missing data point date (june 2018 in this case), have that be the end point, and then subtract 12 from it to get to the start?

for example

smpl date of last data point minus 12 date of last data point
scalar test = @mean(data)
smpl @all

Re: Scalar of average of last 12 months

Posted: Wed Jul 11, 2018 9:57 am
by startz
See if @movav helps.

Re: Scalar of average of last 12 months

Posted: Wed Jul 11, 2018 10:05 am
by EViews Matt
Hello,

Something along this line should work,

Code: Select all

%tmp = @datestr(@dateadd(@dateval(data.@last), -11, "MM")) + " " + data.@last
smpl %tmp
scalar test = @mean(data)
smpl @all