Peggy--
There is a subtle distinction which may have gotten lost in the
shuffle--Maarten's approach (you have to insert an "=0" after "gen
double totalmg" in his example to make it work) puts missing for the
total if any of the components are missing, whereas the -egen-
approach of Ricardo assumes any missings are zero. I prefer Maarten's
approach for that reason.
E.g.:
clear
set seed 1234567
set obs 10
forv i=1/10 {
qui g mg_`i'=uniform() if uniform()>.1
}
egen totalrsum=rsum(mg_1-mg_10)
gen double totalmg=0
foreach var of varlist mg_* {
qui replace totalmg = totalmg + `var'
}
li total*, noo
On 7/26/07, P chrisman <[email protected]> wrote:
egen totalmg=rsum(mg_1-mg_108) worked great! Thanks for the assistance. pc
*
* 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/