Hi,
I am trying to assign my variables to local macros so that I can use them more easily in my models:
local VS1 V1 V2 V3 V4
local VS2 V5 V6 V7
local VS3 V8 V9 V10
V1 to V4 should always be in my model. But, I want to try adding two groups of variables to my control variables to check the robustness of the models. One group is V5 to V7 and the second group is V8 to V10.
This is what I did:
foreach v of varlist `VS2' `VS3'{
display "This is the DiD using `v' as the imputation method"
diff y , p( period) t(treat) cov(`VS1' `v') kernel id(id)
}
Models are run. But, the code is not doing what I want it to do. Insteda, it runs the model in the following order
1- V1 V2 V3 V4 V5
2- V1 V2 V3 V4 V6
3- V1 V2 V3 V4 V7
4- V1 V2 V3 V4 V8
A solution was the following (expanding the macro twice)
local VS1 V1 V2 V3 V4
local VS2 V5 V6 V7
local VS3 V8 V9 V10
local u VS2 VS3
foreach var of local u{
display " This is the DiD using ``u'' as the imputation method"
diff y , p( period) t(treat) cov(`VS1' ``v'') kernel id(id)
}
This worked. But, I still wonder why the first method does not do what the second method does.
Thanks,
Navid
I am trying to assign my variables to local macros so that I can use them more easily in my models:
local VS1 V1 V2 V3 V4
local VS2 V5 V6 V7
local VS3 V8 V9 V10
V1 to V4 should always be in my model. But, I want to try adding two groups of variables to my control variables to check the robustness of the models. One group is V5 to V7 and the second group is V8 to V10.
This is what I did:
foreach v of varlist `VS2' `VS3'{
display "This is the DiD using `v' as the imputation method"
diff y , p( period) t(treat) cov(`VS1' `v') kernel id(id)
}
Models are run. But, the code is not doing what I want it to do. Insteda, it runs the model in the following order
1- V1 V2 V3 V4 V5
2- V1 V2 V3 V4 V6
3- V1 V2 V3 V4 V7
4- V1 V2 V3 V4 V8
A solution was the following (expanding the macro twice)
local VS1 V1 V2 V3 V4
local VS2 V5 V6 V7
local VS3 V8 V9 V10
local u VS2 VS3
foreach var of local u{
display " This is the DiD using ``u'' as the imputation method"
diff y , p( period) t(treat) cov(`VS1' ``v'') kernel id(id)
}
This worked. But, I still wonder why the first method does not do what the second method does.
Thanks,
Navid
Comment