Dear Statalist,
I have several regression models with always the same variable of interest but with different outcomes. I would like to save the coefficients from my main variable of interest in the same Excel sheet (or tabulate them in Stata if possible).
I am using the following loop to run my regression
poisson outcome1 i.year i.age_cat i.education i.employment i.rural group_*, irr vce(robust)
poisson outcome2 i.year i.age_cat i.education i.employment i.rural group_*, irr vce(robust)
poisson outcome3 i.year i.age_cat i.education i.employment i.rural group_*, irr vce(robust)
foreach num of numlist 1/10 {
tab group if group==`num'
poisson outcome1 i.year i.age_cat i.education i.employment i.rural if group==`num', irr vce(robust)
poisson outcome2 i.year i.age_cat i.education i.employment i.rural if group==`num', irr vce(robust)
poisson outcome3 i.year i.age_cat i.education i.employment i.rural if group==`num', irr vce(robust)
}
The code produces 33 regression models. My main variable of interest is time (2010,2011,2012 with 2010 as ref) and I am interested in the RR+CI for the 2011 and 2012 coefficient for each regression model
If I use the option coeflegend, Stata tells me that results I am interested in are stored as _b[2011.year] and _b[2012.year]. I should be able to store them all and either tabulate in Stata or save them in Excel but I am not sure how.
I would need something as follow:
I know I could produce such table manually but I am trying to polish my code to make it more efficient. Thanks in advance.
I have several regression models with always the same variable of interest but with different outcomes. I would like to save the coefficients from my main variable of interest in the same Excel sheet (or tabulate them in Stata if possible).
I am using the following loop to run my regression
poisson outcome1 i.year i.age_cat i.education i.employment i.rural group_*, irr vce(robust)
poisson outcome2 i.year i.age_cat i.education i.employment i.rural group_*, irr vce(robust)
poisson outcome3 i.year i.age_cat i.education i.employment i.rural group_*, irr vce(robust)
foreach num of numlist 1/10 {
tab group if group==`num'
poisson outcome1 i.year i.age_cat i.education i.employment i.rural if group==`num', irr vce(robust)
poisson outcome2 i.year i.age_cat i.education i.employment i.rural if group==`num', irr vce(robust)
poisson outcome3 i.year i.age_cat i.education i.employment i.rural if group==`num', irr vce(robust)
}
The code produces 33 regression models. My main variable of interest is time (2010,2011,2012 with 2010 as ref) and I am interested in the RR+CI for the 2011 and 2012 coefficient for each regression model
If I use the option coeflegend, Stata tells me that results I am interested in are stored as _b[2011.year] and _b[2012.year]. I should be able to store them all and either tabulate in Stata or save them in Excel but I am not sure how.
I would need something as follow:
Group | Outcome | RR | LCI | UCI |
1 | 1 | .. | .. | .. |
1 | 2 | .. | .. | .. |
1 | 3 | .. | .. | .. |
2 | 1 | .. | .. | .. |
I know I could produce such table manually but I am trying to polish my code to make it more efficient. Thanks in advance.
Comment