Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Overriding a loop if 0 observations using tabstat
From
sara khan <[email protected]>
To
[email protected]
Subject
st: Overriding a loop if 0 observations using tabstat
Date
Tue, 27 Apr 2010 11:29:51 +0100
Dear Statalisters
I am having problems with a loop (1 below) that contains tabstat and
would appreciate any advice.
In the command below, there are 0 observations when `i'=0 and
`y'=male. I get a message saying no observations and the loop stops.
However, when I run the loop using the tab command (for example, 2
below), the loop does not terminate when there are 0 observations but
continues to cycle through all values.
How can I get the first command to override 0 observations?
Many thanks,
1.
foreach i in 0 1 2 3 4 5 {
foreach y in male singlet{
di "Var =`y' & GA=`i'"
tabstat bwtg if myga==`i' & intab1==1 & admit_ic==1 & bwtg<., stat(n
mean median) by(`y') col(stat) f(%9.0g) notot nosep
}
}
2.
foreach i in 0 1 2 3 4 5 {
foreach y in male singlet{
di "Var =`y' & GA=`i'"
tab `y' if myga==`i' & intab1==1 & admit_ic==1 & bwtg<.
}
}
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/