Statalisters:
I have a data set that consists of cohorts of firms, their ratings, and
their default status (so there are three fields: cohort, default1,
rating). I am trying to loop over each cohort and take the average of
the cohort gini scores using roctab rather than pooling the cohort
data. The problem is that commands that make looping easy are not
available with roctab (e.g. by, if).
The code I've written doesn't seem to do the trick. I would appreciate
any pointers the Stata community could provide. Many thanks.
Here's my code:
use "dataset"
preserve
mat A=J(10,1,.)
forvalues i=1/10 {
egen j=`i'+1994
keep if cohort==d(01jan`j')
quietly roctab default1 rating, lorenz summary
mat A[`i',1]=r(gini)
restore, preserve
}
svmat A, name(arscore)
summarize arscore
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/