Page 1 of 1

dates in @elem

Posted: Thu Jul 27, 2017 12:23 pm
by EviewsUser1
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?

Re: dates in @elem

Posted: Thu Jul 27, 2017 12:56 pm
by EViews Gareth

Code: Select all

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

Re: dates in @elem

Posted: Fri Jun 08, 2018 10:54 am
by jccondi
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?

Re: dates in @elem

Posted: Fri Jun 08, 2018 11:39 am
by EViews Matt
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.

Re: dates in @elem

Posted: Fri Jun 08, 2018 12:47 pm
by jccondi
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.

Re: dates in @elem

Posted: Fri Jun 08, 2018 2:30 pm
by EViews Matt
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"))

Re: dates in @elem

Posted: Mon Feb 10, 2020 7:08 am
by Bjellerup
Hi Matt,

I'm still struggling with this. I have a workfile in quarterly format. At the start of the program file I have

%sobs="1993Q1"

and then later on I have (rebasing a series)

series p1us = pceus/@elem(pceus,"%sobs")

but it doesn't work. I thought I knew what to do using @dateval and @datestr, but as it turns out, I didn't. Could please help me out?

Rgds,

MÃ¥rten

Re: dates in @elem

Posted: Mon Feb 10, 2020 7:15 am
by EViews Gareth
Remove the quotes in @elem

Re: dates in @elem

Posted: Mon Feb 10, 2020 7:24 am
by Bjellerup
Thanks! Strange, I tried that earlier and it didn't work. Must have got it wrong in some other way I guess.

Re: dates in @elem

Posted: Mon Feb 10, 2020 8:34 am
by Bjellerup
Hi again,

Later in the program I'm trying to create a loop that rolls one step forward at a time. Unfortunately, I don't get the date format right.

I'm trying something like (where %sobs and %fobs are defined earlier as "1993q1" and "2008q1")

for !i=1 to !nrolls step 1
%first=%sobs
%last=%fobs+!i

I suspect I need to tranform %fobs in the last line but I don't understand how. Do I mix string and scalar here?

Re: dates in @elem

Posted: Mon Feb 10, 2020 8:40 am
by EViews Gareth
Use the @dateadd function, or a mixture of @dtoo and @otod and @dateval/@datestr to convert from string to date to observation number and back again.

Re: dates in @elem

Posted: Wed Feb 12, 2020 5:00 am
by mamo
Depending on what you want to do with the rolling samples, you may also just enlarge the sample stepwise as follows

Code: Select all

%sobs="1993Q1"
%fobs="2008q1"
!nrolls=10

for !i=1 to !nrolls step 1
   smpl %sobs %fobs+!i
   ' do sth. here with the enlarged sample
next