Store a date and use in multiple sample

For questions regarding programming in the EViews programming language.

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

BatLaMenace
Posts: 2
Joined: Tue Feb 27, 2018 11:21 am

Store a date and use in multiple sample

Postby BatLaMenace » Wed Sep 19, 2018 8:01 am

Hi all,

I'm writing a programme in EViews for forecasting purpose. As it is made to be re-used at each forecasting exercise, I'd like to define the starting date (e.g. as of now "2018q3") in the beginning of the programme and then use it through the programme to define estimation samples. I don't know if this introduction is very clear. Maybe the code I wrote would be more informative:

Code: Select all

%prev_start = "2018q3"

[...]

delete(noerr) s_xtr
sample s_xtr @first %prev_start-1      'Using the date to define estimation sample (and I have multiple estimation samples to do)
smpl s_xtr
equation xtr_ct.ls ... bla bla ...

[...]

delete(noerr) s_ulc
sample s_ulc "2004q1" %prev_start-1      'See: re-using it now for another estimation sample
smpl s_ulc
equation ulc_ct.ls ... bla bla ...



The above code runs well, but it has to be ran all at once (otherwise, EViews loses the %prev_start from its memory). This is not very convenient as I have to run aaaaaaall my code when updating a single equation.

Is there a way to make the date more permanent in EViews' memory? I tried by doing:

Code: Select all

string prev_start "2018q3"
sample s_xxx @first prev_start


But it does not run...

Is there any possibility to make this date more sticky into the memory ?

Thanks, all the best

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

Re: Store a date and use in multiple sample

Postby EViews Gareth » Wed Sep 19, 2018 8:31 am

Code: Select all

string prev_start = "2018q3"
sample s_xxx @first {prev_start}


As an aside, you can programmatically determine the current quarter:

Code: Select all

string prev_start = @strnow("YYYY[q]Q")
Follow us on Twitter @IHSEViews

BatLaMenace
Posts: 2
Joined: Tue Feb 27, 2018 11:21 am

Re: Store a date and use in multiple sample

Postby BatLaMenace » Thu Sep 20, 2018 12:14 am

Works great ! The almighty EViews Gareth has striked again ! Many thanks


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 25 guests