how can I retrieve the last obersation of a series
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
how can I retrieve the last obersation of a series
How can I retrieve the value of the last observation of a series?
For example one series ends in 2009m12 and the other in 2010m12.
Do you have a code example?
Thanks a lot.
reep
For example one series ends in 2009m12 and the other in 2010m12.
Do you have a code example?
Thanks a lot.
reep
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: how can I retrieve the last obersation of a series
Code: Select all
=@last(series)
Re: how can I retrieve the last obersation of a series
Thanks for the quick response.
Re: how can I retrieve the last obersation of a series
Sorry, to bother you again. But how can I now retrieve also the date for this observation in form of string?
Thanks.
Thanks.
Re: how can I retrieve the last obersation of a series
Sorry, one more question.
Why does the following code not work? Do you have an idea?
scalar test = @last({%ser})
Thanks.
Why does the following code not work? Do you have an idea?
scalar test = @last({%ser})
Thanks.
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: how can I retrieve the last obersation of a series
Should work. Works for me.
Code: Select all
%ser="ddiftbill3m"
scalar test = @last({%ser})
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: how can I retrieve the last obersation of a series
As to the earlier question about the string representation. This isn't particularly elegant but I think it should work. Give it a test drive.
The @LAST isn't part of this calculation but is there so you can check the value against the observation string. You can delete the temps LASTID and DATEVAL if you want. You can also supply formatting information to the @DATESTR function to format the string the way you want it. There may be better ways to do this...
Code: Select all
%ser="tbill3m"
smpl @all
scalar lastid = @ilast({%ser})-1 ' get last obs id
scalar lastval = @last({%ssr}) ' get last value
series dateval = @sum(@date, "@all if @trend=lastid") ' set sample to this obs and get the date number
string datestr = @datestr(@max(dateval)) ' get the date string
Re: how can I retrieve the last obersation of a series
thanks a lot.
I guess the command @last({%ser}) is not working because I haven't updated of Eviews 6 for a while at my work computer. At home it works fine.
Further, I noticed that the functions @last() and @ilast() work with Eviews 6 although they are not described in the command reference. I found a description only in Eviews 7 manual.
I guess the command @last({%ser}) is not working because I haven't updated of Eviews 6 for a while at my work computer. At home it works fine.
Further, I noticed that the functions @last() and @ilast() work with Eviews 6 although they are not described in the command reference. I found a description only in Eviews 7 manual.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: how can I retrieve the last obersation of a series
In EViews 7 you can just do:As to the earlier question about the string representation. This isn't particularly elegant but I think it should work. Give it a test drive.The @LAST isn't part of this calculation but is there so you can check the value against the observation string. You can delete the temps LASTID and DATEVAL if you want. You can also supply formatting information to the @DATESTR function to format the string the way you want it. There may be better ways to do this...Code: Select all
%ser="tbill3m" smpl @all scalar lastid = @ilast({%ser})-1 ' get last obs id scalar lastval = @last({%ssr}) ' get last value series dateval = @sum(@date, "@all if @trend=lastid") ' set sample to this obs and get the date number string datestr = @datestr(@max(dateval)) ' get the date string
Code: Select all
string datestr = {%ser}.@last
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: how can I retrieve the last obersation of a series
Which is why Gareth lobbied to add it...I forgot about that one.
Re: how can I retrieve the last obersation of a series
Thank you. Everything works fine now.
Re: how can I retrieve the last obersation of a series
Hi,
I have similar problem that I cannot solve. I have a series which contains NAs and 1s. For example:
NA
NA
NA
1
NA
1
1
NA
NA
I would like to fill with 1s the series with 1s from the first observation including NA until the last 1s so I will get something like:
1
1
1
1
1
1
NA
NA
I have tried something like smpl 1990.1 @last.series (the page starts in 1990q1 so it is fine) and then series = 1 but it does not like the way I restrict the sample. Which is the correct way of doing of restricting the sample to the last non na.
Thanks a lot.
Fede
I have similar problem that I cannot solve. I have a series which contains NAs and 1s. For example:
NA
NA
NA
1
NA
1
1
NA
NA
I would like to fill with 1s the series with 1s from the first observation including NA until the last 1s so I will get something like:
1
1
1
1
1
1
NA
NA
I have tried something like smpl 1990.1 @last.series (the page starts in 1990q1 so it is fine) and then series = 1 but it does not like the way I restrict the sample. Which is the correct way of doing of restricting the sample to the last non na.
Thanks a lot.
Fede
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: how can I retrieve the last obersation of a series
Code: Select all
%last = SERIES.@last
smpl @first {%last}
Re: how can I retrieve the last obersation of a series
You make it look so easy...
Thanks a lot!!!
Thanks a lot!!!
Who is online
Users browsing this forum: No registered users and 2 guests
