Hello,
I have a question about saving individual results while running a loop. I'm trying to compute the annual state-level gini coefficient across several states and years, using fastgini. The basic command (in practice, I have a lot more states and years) is:
foreach s in 6 8 10 {
forval i = 1990(1)2000 {
fastgini var1 if state == `s' & year == `i'
}
}
(Since fastgini doesn't support "by," I can't run "fastgini var1, by(state year)" and get a table of results.)
What I want to produce is a file that has a column for state, a column for year, and a column for the gini output. So I figure I need to put something after the "fastgini var1" line to save each output, but I'm not sure what. Ideally, I'd like to be able to save each iteration to the same file, just appending each new iteration to the end of the file. But I could also save each output to a separate file and append them all at the end.
Some fastgini-specific features that could be helpful:
Running fastgini produces an output like this:
. fastgini var1
gini coefficient = 0.707707707707
According to the .hlp file, fastgini's output is stored in r().
Thanks for any suggestions!
John
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/