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

Re: st: proceeding beyond roctab 2000 error msg

From   Gary Longton <>
Subject   Re: st: proceeding beyond roctab 2000 error msg
Date   Mon, 31 May 2004 18:09:43 -0700

Tonya Cropper wrote:

I am using the  roctab command (Receiver Operating Characteristic (ROC)
analysis) and I get a
"outcome does not vary   r(2000) " error message.

I understand why I get the message.  I am performing the roctab command in a
three tier loop that includes various if statement conditions based on
different values of other variables.  I append observations to a file of
each resulting  std error and area.  To isolate and remove the
variables/conditions will cause me to forgo the loop and perform dozens of
roctab commands individually.  I would like to know is there any possible
way to proceed beyond the error message when the outcome does not vary?
Use -capture- to suppress the error message and capture the return code.
see help for -capture-, or the manual [P] capture, [U] chapt 21.
The captured return code (nonzero if there was an error) can then be used to write an appropriate result record for the conditions resulting in an error.
You don't say how you are generating your result file, but if you were using, say, the -postfile- commands, this might look something like:
sysuse auto, clear
tempname pfile
postfile `pfile' foreign auc se badrecord using ${tdr}captest, replace
forvalues i = 1/5 { capture roctab foreign weight if rep78 == `i'
if _rc ~= 0 {
post `pfile' (`i') (.) (.) (1)
else {
post `pfile' (`i') (`r(area)') (`r(se)') (0)
postclose `pfile'

- Gary

* For searches and help try:

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