Good catch, David and Austin, using summarize would fail in an
instance where one had balanced +ve and -ve nonzero values.
In the interest of parsimony, one use a cond() instead of the
if...else to handle string/numeric identification which gives:
// Remove empty variables from dataset
foreach var of varlist * {
capture confirm string variable `var'
quietly count if `var' == ///
`=cond(!_rc,`""""',"0")'| mi(`var')
if r(N) == c(N) {
drop `var'
noisily display as txt "Dropping " as result "`var'"
}
}
*
* 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/