Hello,
I'm running a diff-in-diff using a policy with three phases of treatment. There's the issue of staggered treatment, but I still want to see the results of the separate phases.
Suppose I have two cohorts 0 and 1 which I use as the "before-after" of the diff-in-diff. The states that were treated in phases 1, 2 and 3 were (A, B, C), (D, E, F) and (G, H, I) respectively. I want to run a diff-in-diff for each phase by dropping the treated states in the other phases. E.g. for phase 1, I drop (D, E, F) and (G, H, I) and compare (A, B, C) to the control/remaining states. Since I'll have to do this for each phase and a bunch of outcome variables, I thought using local macros and running a loop over them would be useful.
My code looks like this:
use Data, clear
local all_trt_states " "A" "B" "C" " " "D" "E" "F" " " "G" "H" "I" "
foreach s of local all_trt_states {
local curr_trt_states " `s' "
local drp_trt_states: list all_trt_states - curr_trt_states
foreach d of local drp_trt_states {
drop if state==" `d' "
}
gen trt_p1=0
foreach s1 in " `s' " {
replace trt_p1=1 if state==" `s1' "
}
reg outcome i.trt_p1##i.cohort
}
The following line is giving me an error (invalid syntax):
local curr_trt_states " `s' "
What am I doing wrong here?
Thank you in advance.
Best,
Amrita Sanyal.
0 Response to Issues with local macro
Post a Comment