Last/First non-NA observation
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Last/First non-NA observation
How can I obtain the first or last non-na observation of a series?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13583
- Joined: Tue Sep 16, 2008 5:38 pm
There is currently no built-in function to return the first or the last non-na observation of a series. However, you can do this with relative ease in EViews with the following example. Just replace the "x" with the name of the series which you want to obtain the date range. The program below returns the first (last) non-NA observation as an numerical value in scalar "first" ("last") while the actual dates in strings will be placed in %firstdate (%lastdate)
Code: Select all
%ser = "x"
smpl @all
series temp = @recode({%ser}<>na,@trend,na)+1
scalar first = @min(temp)
scalar last = @max(temp)
%firstdate=@otod(first)
%lastdate=@otod(last)
Re: Last/First non-NA observation
Hi Gareth,
Is there a way that I can find the date on which the first non- na observation falls.
for instance, if I find first non-na using @first (Series)
I want to find the date associated with that particular value
I tried to use @otod as well. Can you please help me.
Thanks in advance,
Saranya
Is there a way that I can find the date on which the first non- na observation falls.
for instance, if I find first non-na using @first (Series)
I want to find the date associated with that particular value
I tried to use @otod as well. Can you please help me.
Thanks in advance,
Saranya
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13583
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Last/First non-NA observation
series.@first
Who is online
Users browsing this forum: No registered users and 2 guests
