dates in @elem
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- Posts: 37
- Joined: Thu Aug 28, 2014 8:08 am
dates in @elem
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?
%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?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Re: dates in @elem
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
Re: dates in @elem
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?
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 Developer
- Posts: 562
- Joined: Thu Apr 25, 2013 7:48 pm
Re: dates in @elem
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.
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
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 Developer
- Posts: 562
- Joined: Thu Apr 25, 2013 7:48 pm
Re: dates in @elem
If your "dates" are just simple observation numbers, you can create the adjusted date string simply as,
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 = @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
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
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
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Re: dates in @elem
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
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?
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?
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13315
- Joined: Tue Sep 16, 2008 5:38 pm
Re: dates in @elem
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.
Follow us on Twitter @IHSEViews
Re: dates in @elem
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
Who is online
Users browsing this forum: No registered users and 23 guests