Dear Statalist Members,
I am trying to run a number of bivariate regressions using a loop and saving the results to a .dta dataset using regsave. I have a list of y variables and a list of x variables, and I need to regress each y var on each x var, and save the regression results into the same column. Here is the code I am running:
My problem is, regsave gives me a "Warning: width of using dataset has not increased. Values may have been overwritten" after each output dataset is written. When I look at the dataset generated, the constant, constant coefficient, constant se, observation number N, and r2 from each regression have been overwritten and replaced with those from the last regression that was run. All the coefficients from the xvar and their se are correct. An example output dataset yvar1regs.dta for the regressions with yvar yvar1 looks like this:
What I want is this:
I have looked at the regsave help file and it does not mention how I might solve this problem, nor did I encounter any posts from Statalist that could shed light on my conundrum. I would greatly appreciate your help. Thank you very much!
I am trying to run a number of bivariate regressions using a loop and saving the results to a .dta dataset using regsave. I have a list of y variables and a list of x variables, and I need to regress each y var on each x var, and save the regression results into the same column. Here is the code I am running:
Code:
local yvar `" "yvar1" "yvar2" "yvar3" "yvar4" yvar5" "' local xvar `" "xvar1" "xvar2" "xvar3" "xvar4" "xvar5" "xvar6" "xvar7" "' foreach y of local yvar { local append replace foreach x of local xvar { qui reg `y' `x' regsave using `y'regs, `append' table(`y', format(%7.2f) parentheses(stderr) asterisk()) local append append } }
var | yvar1 |
xvar1_coef | 0.15*** |
xvar1_stderr | (0.02) |
xvar2_coef | 0.20*** |
xvar2_stderr | (0.01) |
xvar3_coef | 0.25*** |
xvar3_stderr | (0.05) |
xvar4_coef | 0.30*** |
xvar4_stderr | (0.05) |
... | ... |
_cons_coef | 0.33*** |
_cons_stderr | (0.01) |
N | 1000 |
r | 0.21 |
What I want is this:
var | yvar1 |
xvar1_coef | 0.15*** |
xvar1_stderr | (0.02) |
_cons_coef | 0.22*** |
_cons_stderr | (0.03) |
N | 1300 |
r2 | 0.13 |
... | ... |
xvar7_coef | 0.20*** |
xvar7_stderr | (0.01) |
_cons_coef | 0.33*** |
_cons_stderr | (0.01) |
N | 1000 |
r | 0.21 |
I have looked at the regsave help file and it does not mention how I might solve this problem, nor did I encounter any posts from Statalist that could shed light on my conundrum. I would greatly appreciate your help. Thank you very much!
Comment