Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73370

Export of results to Excel (or in Stata) after running loops in a simulation

$
0
0
Hello!
I have a problem with exporting/saving simulation results after every run from Stata to Excel or save them in Stata.

I am running a simulation 1000 times and after I code the following:

Start of the simulation:

local sim = 1000
forval i = 1/`sim' {
local seed = 123456 + `i'
set seed `seed'
.
.
.

Then I calculate the results, I would like to save:

egen x_C = xtile(C), nq(10)
egen x_S = xtile(S), nq(10)

forval y = 1/10{
egen C_`y' = mean(C) if x_C == `y'
egen S_`y' = mean(S) if x_C == `y'
}

Now I run this simulation 1000 times and I would like to save the results for every run into excel.
I am interested in the results for C_`y' and S_`y' after every run of the 1000 simulations.
I would like to have the results in Excel or Stata for every Decile, so I can calculate a mean from the 1000 results for these 20 variable (10 each).

I tried, but can not find a solution.
Could someone maybe help me with this problem?


Thanks a lot in advance!

Best regards
Anela Kien

Viewing all articles
Browse latest Browse all 73370

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>