Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: looping with roctab


From   "David T. Hamilton" <[email protected]>
To   [email protected]
Subject   st: looping with roctab
Date   Thu, 8 Sep 2005 21:53:14 -0400

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index