dates in @elem

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator

EviewsUser1
Posts: 30
Joined: Thu Aug 28, 2014 8:08 am

dates in @elem

Postby EviewsUser1 » Thu Jul 27, 2017 12:23 pm

I define the start date of the sample:

%start="1984q1"

and I want to extract a single data point for that series dat using @elem

scalar first_actual=@elem(dat,"1984q1")

but instead of using "1984q1" I would like to use %start

but that does not work. Any suggestions?

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

Re: dates in @elem

Postby EViews Gareth » Thu Jul 27, 2017 12:56 pm

Code: Select all

wfcreate q 1980 2000
series dat=nrnd
%start = "1984q1"
scalar first_actual=@elem(dat,%start)
show first_actual
Follow us on Twitter @IHSEViews

jccondi
Posts: 4
Joined: Fri Jun 01, 2018 8:02 am

Re: dates in @elem

Postby jccondi » Fri Jun 08, 2018 10:54 am

Hi,

I'm trying to do something similar. I would like to update some series to a date inputed by a program. For example, my group is like this:

serie1/@elem(serie1, %0-360)*100

Where %0 is the given date. But unfortunatelly, it doesn't work.
So, basically, what I need is to update my series taking in consideration a given period, every time I run the program. Is that possible?

EViews Matt
EViews Developer
Posts: 262
Joined: Thu Apr 25, 2013 7:48 pm

Re: dates in @elem

Postby EViews Matt » Fri Jun 08, 2018 11:39 am

Hello,

The second argument to @elem, the date, cannot be an expression of the form you've shown. You need to create the date you want before @elem.

jccondi
Posts: 4
Joined: Fri Jun 01, 2018 8:02 am

Re: dates in @elem

Postby jccondi » Fri Jun 08, 2018 12:47 pm

Thanks! How can I create such date? Is there an especial element to do it in Eviews? I've already tried scalar, but it didn't work.

EViews Matt
EViews Developer
Posts: 262
Joined: Thu Apr 25, 2013 7:48 pm

Re: dates in @elem

Postby EViews Matt » Fri Jun 08, 2018 2:30 pm

If your "dates" are just simple observation numbers, you can create the adjusted date string simply as,

Code: Select all

%tmp = @str(%0 - 360)

However, if you're dealing with formatted date strings, e.g., "1/1/1990", then @dateadd should be used to perform the adjustment. Since @dateadd operates on EViews' date numbers rather than data strings, some conversion to/from date numbers is also needed. For example,

Code: Select all

%tmp = @datestr(@dateadd(@dateval(%0), -360, "DD"))


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 9 guests