"Dynamic" YTD
Posted: Wed May 22, 2019 3:33 pm
Hi,
I'm new to Eviews (currently using version 10) so I'll try my best to explain what my issue is; I'm trying to create a piece of code to give me a year-to-date (YTD) value for monthly series (which is different from the @YTD that already exists). In this instance year YTD is taking the average of the monthly observations so far in 2019 divided by the same months average for 2018.
I.e., if we have housing starts (hssa in the code below) till April 2019, the YTD would be
(average 2019m1-2019m4) / (average 2018m1-2018m4). When data for May 2019 comes out the formula should change to (average 2019m1-2019m5) / (average 2018m1-2018m5).
In my code below I get an error message for the "@last(-12)" saying "Error in Sample: Illegal date @LAST(.". I'm trying to create the average value for 2018 by lagging the most recent observation (2019m4) by 12 to get 2018m4
genr hssa_ytd = (@mean(hssa, "2019m1 @last"))/(@mean(hssa, "2018m1 @last(-12)")
Has anyone come across a similar issue and are willing to share their solution?
Any input is greatly appreciated!
Thank you so much,
Joachim
I'm new to Eviews (currently using version 10) so I'll try my best to explain what my issue is; I'm trying to create a piece of code to give me a year-to-date (YTD) value for monthly series (which is different from the @YTD that already exists). In this instance year YTD is taking the average of the monthly observations so far in 2019 divided by the same months average for 2018.
I.e., if we have housing starts (hssa in the code below) till April 2019, the YTD would be
(average 2019m1-2019m4) / (average 2018m1-2018m4). When data for May 2019 comes out the formula should change to (average 2019m1-2019m5) / (average 2018m1-2018m5).
In my code below I get an error message for the "@last(-12)" saying "Error in Sample: Illegal date @LAST(.". I'm trying to create the average value for 2018 by lagging the most recent observation (2019m4) by 12 to get 2018m4
genr hssa_ytd = (@mean(hssa, "2019m1 @last"))/(@mean(hssa, "2018m1 @last(-12)")
Has anyone come across a similar issue and are willing to share their solution?
Any input is greatly appreciated!
Thank you so much,
Joachim