I would like to run several regression via a foreach-loop, calculate marginal effects, store and compare them. So far I managed to calculate the loop. I am able to store normal estimates in a table. I can access one marginal effect at a time, since its in a matrix object. That's where I got stuck. Related posts are: Here is a MWE:

HTML Code:
*************************************************
* Load Panel Data
*************************************************
webuse nlswork, clear
xtset idcode

*************************************************
* Loop for different outcomes
local outcomes "ln_wage hours wks_work"
foreach o of local outcomes {
quietly xtreg `o' age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure, fe
estimates store reg_`o'
}
estimates table reg_ln_wage reg_hours reg_wks_work
*************************************************

*************************************************
* Loop regressions and save marginal effects (difficult due to matrix object)
local outcomes "ln_wage hours wks_work"
foreach o of local outcomes {
quietly xtreg `o' age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure, fe
margins, dydx(age)
matrix B`o' = r(b)
}
* to be continued
*************************************************
Thank you