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

st: looping with roctab

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


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"

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:

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