Hi
In my dataset I have yearly variable, from 1995 to 2006 and a treatment happening in year 2003. I want to estimate the placebo effect ( that requires a me to generate random fake dummies) then estimate the estimate the difference in difference (DID regression) using all of the randomly generated placebo dummies and I need to store the DID coefficients and take the average of their effect. So in a first step I need to use loop to generate dummies. So I would need my loop outcome total number of dummies that is equal to 14 years (total number of years -2= 16-2). Therefore the first dummy would take on the value of 1 from 2000 and onwards, the second dummy will take the value of 1 in 2001 and zero otherwise, the third dummy would take on the value of 1 in 2002 and zero otherwise... etc. In or to generate this, I used the following loop code
[/
levels of x, local(year) foreach lev of local year {
gen x_`lev'=0 replace x_`lev'=1 if year>x("`lev'") } ]
When I run this loop, I do not get any output in my dataset. Any idea what is wrong in my code ? Many thanks
Related Posts with Using loops to generate dummy for placebo regressions
period to period changeDear Stata users, The dataset I am working on is repeated measures data and it looks as below. I wa…
Testing for parallel trendHello statalists! I have a very beginner question, I am working on a panel dataset trying to estim…
Multiple treatmentsHi I have a panel of roughly 1000 firms across 10 years (2004-2013) in 2 states in the US (CA and PA…
How to import large mdb fileHi, I have to import large .mdb files and transfer into stata file. As the databases are saved in 3…
How to create a dummy within a categorical variable.Hello everyone, i am working on Mergers and Acquisition. I have a variable named "Acquirer Name" whi…
Subscribe to:
Post Comments (Atom)
0 Response to Using loops to generate dummy for placebo regressions
Post a Comment