There are a few ways to make the loop keep going even when there are
errors in some command for some values. One is to prepend a
potentially error-generating command with -cap noi- (see -help
capture- and -help noisily-). Another is to check (within the loop)
to see if you need to execute for each value, e.g.
forvalues c=3/12 {
cap su pctlap`c', meanonly
if _rc==0 {
display " "
display " "
display "Percent Prof/Adv, Language Arts, Grade `a'"
display "School-Level Minimum, Maximum, Mean, & Median"
tabstat pctlap`c', by( stfips) statistics(count min max /*
mean median) casewise format nototal
}
}
Another solution is to specify only the numbers you want in the first place:
numlist "3/8 10/12"
foreach c in `=r(numlist)' {
display " "
display " "
display "Percent Prof/Adv, Language Arts, Grade `a'"
display "School-Level Minimum, Maximum, Mean, & Median"
tabstat pctlap`c', by( stfips) statistics(count min max /*
mean median) casewise format nototal
}
On 2/10/06, Joe McCrary <[email protected]> wrote:
> I'm running a tabstat over 10 grade (3 through 12) over several
> variables. When it gets to grade 9 for one variable, the command stops
> processing because there are no observations for grade 9. Is there a
> way I can force the command to continue to run through grade 10-12?
>
> Thank you.
*
* 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/