you can try the -egen rsum- command and then take the mean, as the sum
of means is equal to mean of sums. for example:
egen rowsum = rsum(V*)
summarize rowsum
scalar z = r(mean)
drop rowsum
2006/7/21, Jeffrey W Ladewig <jeffrey.ladewig@uconn.edu>:
I am using a simple while loop statement (see below) to add the mean of
each
variable in a series. The program runs fine except if one of the
variables
contains all missing values (there are reasons why I need to keep the
variables). If, for instance, the 500th variable contains all missing
values, then the scalar (i.e., average_V`i') for the 500th variable
equals a
missing value (of course), but the additive scalar (i.e., z) from that
point
forward only reports missing values. That is, my additive scalar stops
adding. I have been programming a bypass around each of these
problematic
variables, but is there a command or something that I could use instead?
Thanks!
Example:
scalar z = 0
local i = 1
while `i' <= 1000 {
summarize V`i'
scalar average_V`i'= r(mean)
scalar z= z + average_V`i'
local i = `i' + 1
}