Page 1 of 1

Variable Lags

Posted: Fri Dec 06, 2013 5:23 am
by Fabian2
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!

Re: Variable Lags

Posted: Fri Dec 06, 2013 9:08 am
by EViews Gareth
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.

Re: Variable Lags

Posted: Tue Dec 10, 2013 1:50 am
by Fabian2
Wow, simple as that :o
Thanks!