Last/First non-NA observation

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

Thommo
Posts: 15
Joined: Wed Sep 17, 2008 10:56 am

Last/First non-NA observation

Postby Thommo » Wed Sep 17, 2008 1:58 pm

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

Postby EViews Gareth » Wed Sep 17, 2008 2:17 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)

saranya
Posts: 41
Joined: Wed Nov 16, 2016 5:51 am

Re: Last/First non-NA observation

Postby saranya » Thu Mar 30, 2017 6:43 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13583
Joined: Tue Sep 16, 2008 5:38 pm

Re: Last/First non-NA observation

Postby EViews Gareth » Thu Mar 30, 2017 8:23 am

series.@first


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests