Hi all,
I have 32 countries in my sample, 18 of which have adopted a certain policy, and 14 of which have not. I want to pair each country that has not adopted the policy with each country that has, and then regress over outcomes a,b, ... n, with 18 total outcomes. In addition, I want to store the output from one of the coefficients in each model (it's a diff in diff so, in this case, the interaction between treatment time and the binary indicating adoption). I then want to be able to use those estimates for something else. The system memory, however, does not allow for storing the number of results that I require.
My request may not be clear, so let me explain what I mean. Currently, I have tagged each country that has not adopted the policy a value i = 1/18 and each that has not a value j = 19/32. I then use the following code to run the regressions on each of 18 outcomes within each country pair. I then combine the output from the excel file manually:
Where "adopt" is a binary indicator of policy adoption and "treatment" is the indicator for the post-treatment period. This code produces 252 1x18 excel files, where each stores the results for each outcome among one individual country pair. Combining the excel outputs yields something like this:

It is then easy to import into Stata the combined excel file. My method works, but combining the files is tedious and not ideal for replication purposes.
The crux of my issue is this: how do I store hundreds of regression estimates in a similar format to the excel sheet pictured above, without ever leaving Stata?
I have 32 countries in my sample, 18 of which have adopted a certain policy, and 14 of which have not. I want to pair each country that has not adopted the policy with each country that has, and then regress over outcomes a,b, ... n, with 18 total outcomes. In addition, I want to store the output from one of the coefficients in each model (it's a diff in diff so, in this case, the interaction between treatment time and the binary indicating adoption). I then want to be able to use those estimates for something else. The system memory, however, does not allow for storing the number of results that I require.
My request may not be clear, so let me explain what I mean. Currently, I have tagged each country that has not adopted the policy a value i = 1/18 and each that has not a value j = 19/32. I then use the following code to run the regressions on each of 18 outcomes within each country pair. I then combine the output from the excel file manually:
Code:
local tablepath "X~X" local outcomes a b c etc. local covariates x y z etc. est drop _all foreach outcome of local outcomes { forvalues i = 1/14 { forvalues j = 19/32 { eststo: qui reg `outcome' `covariates' if (notadopt_id == `i' | adopt_id == `j') [pw = round(weight, 1)], cluster(countryname) // this regresses all potential pairs of countries } } esttab using "`tablepath'/title_`outcome'.csv", not nostar noobs keep(1.adopt#1.treatment) // write the output to excel est drop _all }
It is then easy to import into Stata the combined excel file. My method works, but combining the files is tedious and not ideal for replication purposes.
The crux of my issue is this: how do I store hundreds of regression estimates in a similar format to the excel sheet pictured above, without ever leaving Stata?
Comment