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
Combine two datasets and estimate values in relation to datesHello, I am doing an event study and posted a question a few days ago, and was able to solve the pr…
Kurtosis of three values always equals 1.5Dear Statalist, I got stuck with a surprising issue today when analyzing a dataset. I wanted to com…
Generating new variable based on the maximum value of a group of variables by countryDear all, I am currently working with a country-level religion adherence dataset which looks as fol…
Stata vs. SAS Differences in Repeated Measures AnovaI have uncovered an interesting issue, and am curious if anybody has an explanation for what I am se…
Using tabstat with macro?I am using BWGHT.DTA with a macro created as: local bwghtvars bwght cigs faminc fatheduc motheduc p…
Subscribe to:
Post Comments (Atom)
0 Response to Using loops to generate dummy for placebo regressions
Post a Comment