mistery in @elem function

For questions regarding programming in the EViews programming language.

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

Novi
Posts: 44
Joined: Sun May 16, 2010 11:48 am

mistery in @elem function

Postby Novi » Wed Dec 07, 2011 8:57 am

Hi Eviews users,
I am very puzzled by a strange results eviews 6 gives me: I want to access element "@first+t" (where t is a predefined scalar) of series x...

the same command :

scalar pr=@elem(x,"@first+t")

will give the right result in one workfile, and 0 in the other workfile, even if in both files the series x has no Na and obviously it has a finite value for the obsrvervation @first+t....is my syntax wrong in any way? can this be a bug?
If any of u has any idea of what's going on please let me know...

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

Re: mistery in @elem function

Postby EViews Gareth » Wed Dec 07, 2011 9:09 am

Code: Select all

scalar pr=@elem(x,"@first+t")
isn't proper syntax for the @elem command. Possibly what you want to do is:

Code: Select all

%date = @otod(t+1) scalar pr = @elem(x, %date)

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

Re: mistery in @elem function

Postby EViews Gareth » Wed Dec 07, 2011 9:11 am

I should also note that you can actually do:

Code: Select all

scalar pr = x(t+1)
although I don't recommend this, since it is confusing when using it with:

Code: Select all

series pr = x(t+1)
since the first example access the t+1th element of X, the second example access the t+1th lead of X, and it can be confusing to figure out which one you're doing.

Novi
Posts: 44
Joined: Sun May 16, 2010 11:48 am

Re: mistery in @elem function

Postby Novi » Wed Dec 07, 2011 9:14 am

Thanks!
I had the feeling that I was missing something stupid... :D


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests