trouble with years in a setcell

For questions regarding programming in the EViews programming language.

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

alps
Posts: 28
Joined: Sun Feb 24, 2013 7:42 am

trouble with years in a setcell

Postby alps » Fri Mar 01, 2013 2:17 pm

Hello,

I would like to put the year and the value of the series correspondingto that year in a table as below. But I keep getting an error. And this is in a loop, so I need to increase it. Could you think of a way to program this?
Thanks a lot
Alps

setcell(for_aus,!j+1, 1,1998Q1+!j)
setcell(for_aus,!j+1, 2,@elem(dlindex,1998Q1+!j))

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

Re: trouble with years in a setcell

Postby EViews Gareth » Fri Mar 01, 2013 2:48 pm

I think I'd just freeze the sheet view of the series:

Code: Select all

freeze(for_aus) dlindex.sheet

alps
Posts: 28
Joined: Sun Feb 24, 2013 7:42 am

Re: trouble with years in a setcell

Postby alps » Fri Mar 01, 2013 3:09 pm

Thanks but I want to add other numbers on this table, so I don't think freeze would work. I copied my program below. Thanks a lot for your help

for !j=1 to end-1
'regular model
smpl 1983Q2+!j-1 1998Q1+!j-1
equation eq_cu_!j.ls(n) dlindex = c(1) + c(2) * dlusd_1 + c(3) * dlindex_1
smpl 1998Q1+!j 1998Q1+!j
forecast eq_cu_f!j

'AR model
smpl 1983Q2+!j-1 1998Q1+!j-1
equation eqAR_cu_!j.ls(n) dlindex = c(1) + c(3) * dlindex_1
smpl 1998Q1+!j 1998Q1+!j
forecast eqAR_cu_f!j

'Random Walk
smpl 1983Q2+!j-1 1998Q1+!j-1
equation eqRW_cu_!j.ls(n) dlindex = c(1) + c(2) * dlusd_1
smpl 1998Q1+!j 1998Q1+!j
forecast eqRW_cu_f!j

setcell(for_aus,1, 2,"lindex")
setcell(for_aus,1, 3,"Model")
setcell(for_aus,1, 4,"AR")
setcell(for_aus,1, 5,"Random Walk")

scalar xx=@elem(dlindex,1998Q1+!j)

setcell(for_aus,!j+1, 1,1998Q1+!j)
setcell(for_aus,!j+1, 2,@elem(dlindex,1998Q1+!j))
'setcell(for_aus,!j+1, 3,@elem(eq_cu_f!j, 1998Q1+!j))
'setcell(for_aus,!j+1, 4,@elem(eqAR_cu_f!j,1998Q1+!j))
'setcell(for_aus,!j+1, 5,@elem(eqRW_cu_f!j,1998Q1+!j))

next

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

Re: trouble with years in a setcell

Postby EViews Gareth » Fri Mar 01, 2013 3:30 pm

I wouldn't bother using setcell then, just stick things in the table directly:

Code: Select all

table(1,3) = "hello"
Also, you probably can't use @elem directly, and you can't calculate dates directly. You'll have to put them into strings first.

alps
Posts: 28
Joined: Sun Feb 24, 2013 7:42 am

Re: trouble with years in a setcell

Postby alps » Fri Mar 01, 2013 3:41 pm

thanks, maybe my question is how to put the dates (or year) to put in a table. Eventually I want to create a table like this

Dleindex RW AR
1998Q1 0.222 0.92 0.322
1998Q2
1998Q3
1998Q4


The issue is to put the date in the table, I cannot that figure it out because 199Q1+!j doesn't work.

Thanks again
Alps

alps
Posts: 28
Joined: Sun Feb 24, 2013 7:42 am

Re: trouble with years in a setcell

Postby alps » Fri Mar 01, 2013 3:51 pm

I get an error message on this command 1998Q1+!j doesn't work.

scalar xx=@elem(dlindex,1998Q1+!j)

Can you think a solution?

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

Re: trouble with years in a setcell

Postby EViews Gareth » Fri Mar 01, 2013 5:04 pm

1998q1+!j makes no sense to EViews. You'll have to use some of the date functions to actually calculate the date you want. Probably something involving a mixture of @dateadd and @dateval and @datestr.

I'll maintain that you're probably best off just using the frozen view of the series though, then adding to that table.

alps
Posts: 28
Joined: Sun Feb 24, 2013 7:42 am

Re: trouble with years in a setcell

Postby alps » Sat Mar 02, 2013 12:03 am

Thanks. yes the statement I put in my previous posting doesn't work, what I want to do is to add the year and the value of more than one series in a table in a loop.

Probably what I was trying to do was not the best apporach.

I am forecasting for a quarter for 3 different equations and I want to store each forecasted value and the corresponding year-quarter in a table.

how can I do that with the freeze command you mentioned.
Thanks a lot
Alps

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

Re: trouble with years in a setcell

Postby EViews Gareth » Sat Mar 02, 2013 3:44 am

Why not put the three forecasted series into a group, then freeze the sheet view of the group?

alps
Posts: 28
Joined: Sun Feb 24, 2013 7:42 am

Re: trouble with years in a setcell

Postby alps » Sat Mar 02, 2013 4:03 am

yes, great idea. thanks a lot.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest