Something like this?
local i = 1
foreach v of varlist <whatever> {
local call `call' (sum) `v' (count) nonmiss`i' = `v'
local ++i
}
collapse `call', by(group)
local i = 1
quietly foreach v of varlist <whatever> {
replace `v' = . if nonmiss`i' == 0
local ++i
}
Nick
[email protected]
Michael Mitchell
Thanks all, both for the general thoughts on the underlying rationale
for this, as well as the practical suggestions. As some noted, I could
do this...
. collapse (sum) x (count) nonmiss=x, by(group)
. replace x=. if nonmiss==0
I have about 100 "x" values, and there is no pattern to the names. All
methods I can think of for ensuring that the "x" values are . when all
members of the group are . involve either substantial typing or a fair
amount of programming. Am I overlooking a simple solution for this?
*
* 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/