Hi.
I have a question on using @date and @obssmpl function.
My goal is to return the first date and last date of a series (say series1) as well as how many observations totally there are in the series.
and eventually return observations of the exact dates from another series. I tried to use both @date and @enddate for the purpose but it
returns errors. Besides, both functions are supposed to return start date and end date of the work file, rather than the start date and end date of non"NA"
observations of my series.
Similar thing happens to !y=series1.@obssmpl.
Could anybody tell me how to return first/last date of a series ( not the two ends of a wf), as well as observation counts?
Thanks for your help.
Question on @date and @obssmpl functions.
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Question on @date and @obssmpl functions.
@obs(seriesname) should always give you the number of observations accounting for missings, as in
To find the starts of the set the sample to the non-missings for your series
then @otods(1) will give you the start date of the sample, and @otods(@obs(seriesname)) will given the end date of the sample, as in
Code: Select all
scalar obs = @obs(series01)Code: Select all
smpl if series1<>naCode: Select all
string firstdate = @otods(1)
string lastdate = @otods(obs)
Re: Question on @date and @obssmpl functions.
Thanks so much for your help.
I want to use the observation of the same date from two different series (s1 and s2), to adjust the first
series. Here is my code but the firstdate string is not recognized. (With or without the quote on firstdate string.)
smpl if s1<>na
string firstdate=@otods(1)
series s1adj=s1*@elem(s2, "firstdate")/@elem(s1, "firstdate")
Also can you tell me if I need to specify the series name for the code: string firstdate=@otods(1). ?
I want to use the observation of the same date from two different series (s1 and s2), to adjust the first
series. Here is my code but the firstdate string is not recognized. (With or without the quote on firstdate string.)
smpl if s1<>na
string firstdate=@otods(1)
series s1adj=s1*@elem(s2, "firstdate")/@elem(s1, "firstdate")
Also can you tell me if I need to specify the series name for the code: string firstdate=@otods(1). ?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Question on @date and @obssmpl functions.
Further to Glenn's answer, you'll probably find the series.@first and series.@last data members useful - I believe they do exactly what you want (return the date of the first non-missing observation).
Using your existing code though, use this:
Using your existing code though, use this:
Code: Select all
smpl if s1<>na
%firstdate=@otods(1)
series s1adj=s1*@elem(s2, %firstdate)/@elem(s1, %firstdate)
Re: Question on @date and @obssmpl functions.
Thank you Gareth for the command. I tried it and it totally works.
Still I have a quick question. Actually I want to extract two first non"NA" dates and compare them, so that I can tell which series is "older"
How can I specify series name in the %firstdate=@otods(1) statement?
Also, is there a way to compare two date string and report which is older? Or to say, can I write something like %firstdate1 > %firstdate2 without
doing any string conversion ?
Thanks so much again!
Still I have a quick question. Actually I want to extract two first non"NA" dates and compare them, so that I can tell which series is "older"
How can I specify series name in the %firstdate=@otods(1) statement?
Also, is there a way to compare two date string and report which is older? Or to say, can I write something like %firstdate1 > %firstdate2 without
doing any string conversion ?
Thanks so much again!
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Question on @date and @obssmpl functions.
Code: Select all
smpl if s1<>na
%firstdate1=@otods(1)
smpl if s2<>na
%firstdate2=@otods(1)
!diff =@datediff(@dateval(%firstdate1), @dateval(%firstdate2),"dd")
Re: Question on @date and @obssmpl functions.
Thanks Gareth again. It totally works now, based on your program!
I just have a quick question about another command. I use series.setconvert to change the default of conversion
method of a series when I was trying to save this serise to a db, so that next time when I extract it from the db,
I don't need to specify again.
I wrote:
myseries.setconvert c nf
store(d=db) myseries
However after I saved it to my db, I double click the series, and the windows shows that the conversion methods are
still default( this is the case for both "low to high" and "high to low" .) Can you tell me how to change this default? Thank you in advance.
I just have a quick question about another command. I use series.setconvert to change the default of conversion
method of a series when I was trying to save this serise to a db, so that next time when I extract it from the db,
I don't need to specify again.
I wrote:
myseries.setconvert c nf
store(d=db) myseries
However after I saved it to my db, I double click the series, and the windows shows that the conversion methods are
still default( this is the case for both "low to high" and "high to low" .) Can you tell me how to change this default? Thank you in advance.
-
EViews Jason
- EViews Developer
- Posts: 870
- Joined: Tue Sep 16, 2008 3:50 pm
Re: Question on @date and @obssmpl functions.
What version of EViews are you using? Be sure that your copy is also up to date. The latest of version EViews 7.1 works as desired.
Re: Question on @date and @obssmpl functions.
Hi Jason. Thank you for your reply.
You are right. I updated it (I didn't know that there is a new update on July 30th) and it works now.
I use Eviews 7 Enterprise version. I realized that I should delete the old series from the database and store new ones.
If I just overwrite, the window doesn't change. In short, It all works perfectly now. Thanks so much again.
You are right. I updated it (I didn't know that there is a new update on July 30th) and it works now.
I use Eviews 7 Enterprise version. I realized that I should delete the old series from the database and store new ones.
If I just overwrite, the window doesn't change. In short, It all works perfectly now. Thanks so much again.
Who is online
Users browsing this forum: No registered users and 1 guest
