Unexpected result with function @datediff
Posted: Tue Aug 04, 2026 2:53 am
Dear Eviews team,
I am using Eviews 14, Jun 16 2026 build.
I obtain an unexpected result with the function @datediff, see attached code.
I would have expected the series lag1 and lag 2 to show identical values all over. In fact, that is the case only in leap years
Can you explain why the series lag1 and lag 2 do not have identical values in all years except in leap years?
Best, mamo
I am using Eviews 14, Jun 16 2026 build.
I obtain an unexpected result with the function @datediff, see attached code.
I would have expected the series lag1 and lag 2 to show identical values all over. In fact, that is the case only in leap years
Can you explain why the series lag1 and lag 2 do not have identical values in all years except in leap years?
Best, mamo
Code: Select all
wfcreate dd 2000 2020
' create annual lag
series lag1=@datediff(@date, @dateadd(@date,1,"A"), "dd")
' crate lagged date series, lagged by one year
series date_lagged=@date(lag1)
' create 2nd lag, as day-difference between @date and lagged date series
series lag2=@datediff(date_lagged, @date, "dd")
' set sample to exclude NAs
smpl 2001 @last ' if @month=1 and @day=1
' define group with the two lag-series
group gr lag1 lag2
' show the group and the difference between the two lage series
gr.sheet(c)