I am a beginner stata user and new to this post. I found this forum was extremely helpful when I google search for stata help.
I have 5 dependent variables and I need to run same regressions for each of the dependent variables. For each dependent variable, I will run three sets of regressions and the only difference between the three sets of regression was one set of interaction terms were using different variables. instead of running one loop for 5 dependent variables three times for each of the three interaction terms and control variables, I think a loop for 5 dependent variables and a within loop for the three interaction terms can make it easier.
Here are my codes:
local ppost t_state##ib2.p_c ---i used this to create a local variable for my interaction terms, which may be wrong
local postdum t_state##ib0.post
local state st##ib2.p_c
local pv `ppost' `postdum' `state'
foreach v of varlist b2 b4 b8 b2 b16{
foreach p of local pv{
xi:svy: reg `v' `p' $charm if r_`v'==1 & family==0
est sto nom_`v'`p'
}
}
the model run only for the first variable and the first interaction terms, which is t_state##ib2.p_c with an error message:
# invalid name
# invalid name
ib2.p_c invalid name
r(7);
I suspect that it was because I did wrong when define local for the interaction terms. I tested the following
display `pv'
invalid matrix stripe;
t_state##ib2.p_c
r(198);
Thank you very much for the help!
Related Posts with try to do a loop within a loop
Difficulties in invoking python in stata 16I am trying to call python into the stata 16 environment but having the below error. Any help would …
Related to Variable transformation & ScalingAdvance sorry for asking such a naive doubt in Stata. I have 2 variables, 1.cash holdings and 2.tota…
Creating an indexHey I want to create an index out of 10 variables, each of them has values on a scale from 1 to 5. I…
is this a correct way to rescale a variable?Hi all, I have an independent variable in my regression that lies between .0000869 and .0610705. It…
Meta-analysis of prevalence data using metaprop commandHi There, I am seeking some help regarding the meta-analysis of the prevalence data using the metap…
Subscribe to:
Post Comments (Atom)
0 Response to try to do a loop within a loop
Post a Comment