Variable Lags

For questions regarding programming in the EViews programming language.

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

Fabian2
Posts: 7
Joined: Fri Aug 23, 2013 2:49 am

Variable Lags

Postby Fabian2 » Fri Dec 06, 2013 5:23 am

Hello everyone,

I have the following problem:
I have a panel data set which is "balanced between starts and ends" meaning to say there are data gaps for single firms in some years but these are filled with NAs.
Now I would like to calculate an index with the data of the preceding year. If the preceding year is a gap, I want to use the data of the first available data in the preceding years. However, data gaps not only occur with a duration of one year but can also be up to six years in duration.
How can I tell eviews to find the first available data record in the preceding years.

I thought of something like this:

Code: Select all

smpl if output_ges<>0 and output_ges(-1)=na for !j=2 to 6 if output_ges(-!j)<>na then exitloop endif next genr output_ges_la=output_ges(-!j)
but this does not work, I guess. An error message says: "-2 is not a valid index for vector-series-coefficient output_ges"

Any ideas on how to solve this?
Thanks!

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

Re: Variable Lags

Postby EViews Gareth » Fri Dec 06, 2013 9:08 am

Can't you just do something like:

Code: Select all

output_ges = @recode(output_ges=na, output_ges(-1), output_ges)
That should work as long as the first observation of each cross-section is not an NA.

Fabian2
Posts: 7
Joined: Fri Aug 23, 2013 2:49 am

Re: Variable Lags

Postby Fabian2 » Tue Dec 10, 2013 1:50 am

Wow, simple as that :o
Thanks!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests