Hi there,

I am sorry if this is a trivial question, but I did not seem to find a satisfactory answer.

I have a housing transaction dataset which I am using for a difference-in-differences analysis. Part of it is the so-called 'Granger Causality Test', which uses to leads and lags to test a certain outcome. To calculate these I have housing characteristics, transaction year, and several difference-in-difference (DiD) variables (treated, treattime and did).

I have DiD and treattime variables for each year in the numlist. How do I tell stata to take a value from the numlist - 1? I've tried it like this, but this doesn't work.

Code:
foreach num of numlist 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 {
    reg lnprice lnsize lnlotsize rooms i.trans_year treated treattime_`num' did_`num-3' did_`num-2' did_`num-1' did_`num+1' did_`num+2' did_`num+3'
    outreg2 using causalitytest, excel nose label cttop(`num')
}
Can anyone help me with this, or is it not possible?

Thanks in advance!