select contiguous sample with no NA

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

cbonham
Posts: 22
Joined: Sat Jul 29, 2017 12:38 pm

select contiguous sample with no NA

Postby cbonham » Tue Sep 10, 2019 8:28 pm

I am running X13 on a long list of series and some of them have a year or so of data at the beginning of the sample followed by 6 months of missing followed by a complete sample of data for two decades. X13 won't run on series with embedded missing values. I originally wrote the code testing for the range of available data using @first and @last on each series to set the sample before running X13. But @first identifies the *first* non-missing observation. I need the first observation with no missing values from that point forward.

I am certain someone has already dealt with this problem.
Aloha
Carl

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: select contiguous sample with no NA

Postby EViews Matt » Wed Sep 11, 2019 9:23 am

Hello,

You can create a temporary series whose @first data member will hold the date/observation you want.

Code: Select all

series tmp = @recode(@cumbnas(x) > 0, na, 1)

cbonham
Posts: 22
Joined: Sat Jul 29, 2017 12:38 pm

Re: select contiguous sample with no NA

Postby cbonham » Wed Sep 11, 2019 10:36 am

Thanks Matt. Maybe my problem was not clear. Here is what I get using the @cumnas function by itself and the @recode temp series you suggested. I am running

Code: Select all

smpl 2001m1 2002m12
series tmp1 = @cumbnas(QE_TRADE)
series tmp2 = @recode(@cumbnas(QE_TRADE) > 0, na, 1)
show QE_TRADE tmp1 tmp2

I shortened the sample to end in 2002m12 to show less data, the issue is the missing values in 2001M7-M12, so I am trying to identify the starting point as 2002M1.

Results:
QE_TRADE TMP1 TMP2
2002M12 60.247 12 NA
2002M11 58.567 12 NA
2002M10 57.437 12 NA
2002M09 57.165 12 NA
2002M08 57.203 12 NA
2002M07 57.176 12 NA
2002M06 56.829 12 NA
2002M05 56.377 12 NA
2002M04 56.069 12 NA
2002M03 56.066 12 NA
2002M02 56.259 12 NA
2002M01 56.952 12 NA
2001M12 NA 13 NA
2001M11 NA 14 NA
2001M10 NA 15 NA
2001M09 NA 16 NA
2001M08 NA 17 NA
2001M07 NA 18 NA
2001M06 59.417 18 NA
2001M05 59.028 18 NA
2001M04 58.970 18 NA
2001M03 59.537 18 NA
2001M02 59.585 18 NA
2001M01 60.203 18 NA

EViews Matt
EViews Developer
Posts: 560
Joined: Thu Apr 25, 2013 7:48 pm

Re: select contiguous sample with no NA

Postby EViews Matt » Wed Sep 11, 2019 2:02 pm

Ah, you must have more NAs after the sample. This alternative should account for the current sample:

Code: Select all

%tmp = @pagesmpl
series tmp = @recode(@cumbnas(x, %tmp) > 0, na, 1)

cbonham
Posts: 22
Joined: Sat Jul 29, 2017 12:38 pm

Re: select contiguous sample with no NA

Postby cbonham » Tue Sep 24, 2019 1:06 pm

Thanks Matt, that does the trick.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 13 guests