Accessing specific values from a series

For questions regarding programming in the EViews programming language.

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

Billaudes
Posts: 6
Joined: Tue Jun 09, 2009 4:07 am

Accessing specific values from a series

Postby Billaudes » Sat Jun 27, 2009 6:45 am

Hi everyone,

I have a time series object called y3_0mp from which I want to access the the 397th, 400th, 403rd, and 406th value (and multiply them with each other). Afterwards reiterate the process with plus 1 values. This is what I have come up with so far:

for !j=0 to 206

series y12_eh_{!j}=(@elem(y3_0mp, @otod(397+{!j})))*(@elem(y3_0mp, @otod(400+{!j}))))*(@elem(y3_0mp, @otod(403+{!j})))*(@elem(y3_0mp, @otod(406+{!j})))


next

However it gives me the followin error message: "Illegal date 397+0". I also tried just the loop in there and it didn't work, any ideas???? I also tried to simply type in the date as it is and it didn't work.

Thanks,
Billaudes
Last edited by Billaudes on Sat Jun 27, 2009 10:03 am, edited 1 time in total.

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

Re: Accessing specific valies from a series

Postby EViews Gareth » Sat Jun 27, 2009 8:07 am

create string variables equal to the dates first, then use the string variables inside the @elem.
Follow us on Twitter @IHSEViews

Billaudes
Posts: 6
Joined: Tue Jun 09, 2009 4:07 am

Re: Accessing specific values from a series

Postby Billaudes » Sat Jun 27, 2009 10:00 am

Hi,

thanks for your response, I am however having difficulties converting those dates to strings, this is what I have tried so far:

y3_0mp=@datestr(yyyy/mm)

other commands also kinda failed (strnow), I think I am declaring the format in a wrong way. my dates are monthly (e.g.1959M02), not sure how the correct format would look like.

Thanks for your help,
Billaudes

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

Re: Accessing specific values from a series

Postby EViews Gareth » Sat Jun 27, 2009 10:50 am

I meant do something like this:

Code: Select all

%date1 = @otod(397+!j)
@elem(y3_0mp,%date1)
Follow us on Twitter @IHSEViews

Billaudes
Posts: 6
Joined: Tue Jun 09, 2009 4:07 am

Re: Accessing specific values from a series

Postby Billaudes » Sat Jun 27, 2009 11:02 am

That is brilliant thank you sooo much, I have been sitting on this quite a while now!!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 32 guests