Hi Statalist,

I have a beginners question.

I use tsvarlist operators (l. , f. s. , etc.) quite extensively, but I am noticing a worrisome issue; despite the description of tsvarlists, these operators do not seem to handle gaps adequately sometimes.

I wrote a little program to show the issue:

Code:
clear

set obs 10

set seed 567
// create random integer variable
generate u1 = runiformint(0, 100)
gen year = .

// create time variable
local year 2000
forvalues n = 1/10{
    replace year = `year' if _n == `n'
    local year = `year' + 1
}

// create a gap after 2007
replace year = year[_n+1] if year > 2007

// declare dataset as time series 
tsset year

// create rolling averages using time-series varlist
gen u1_ra = l.u1 + u1 + F.u1

// creating rolling averages by manually specifying the observation number 
sort year
gen u1_ra_alt = u1[_n-1] + u1[_n] + u1[_n+1]
which results in:


Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float(u1 year u1_ra u1_ra_alt)
59 2000   .   .
69 2001 186 186
58 2002 189 189
62 2003 205 205
85 2004 166 166
19 2005 118 118
14 2006 114 114
81 2007   . 167
72 2009   . 187
34    .   .   .
end
As you can see, using tsvarlist does not create a variable for the year 2007. Why is that? What am I missing? Do I have to use tsfill after all?

Thank you very much!