Hi
I was using egen function rowtotal, when I discovered the following:
I can see in the documentation that rowtotal with option missing require all variables to be missing before the new variables becomes missing.
Just as shown above.
In my world however rowtotal with option missing would be a far more interesting tool if totals only were calculated when all variables were nonmissing ie that test2 above is nonmissing only at row 1.
Is this "almost a bug"? Or is it something for the wishlist?
An extra missingOne option could be a solution?
I was using egen function rowtotal, when I discovered the following:
Code:
. clear . input x1 x2 x3 x1 x2 x3 1. 1 2 3 2. . 2 3 3. . . 3 4. .a .b .c 5. 1 2 .a 6. .c 2 3 7. end . . /* Help egen: rowtotal creates the (row) sum of the variables in varlist, > treating missing as 0.*/ . egen test1 = rowtotal(x*) . /* Help egen: If missing is specified and all values in varlist are missing for > an observation, newvar is set to missing > */ . egen test2 = rowtotal(x*), missing (1 missing value generated) . list +------------------------------+ | x1 x2 x3 test1 test2 | |------------------------------| 1. | 1 2 3 6 6 | 2. | . 2 3 5 5 | 3. | . . 3 3 3 | 4. | .a .b .c 0 . | 5. | 1 2 .a 3 3 | |------------------------------| 6. | .c 2 3 5 5 | +------------------------------+ . end of do-file
Just as shown above.
In my world however rowtotal with option missing would be a far more interesting tool if totals only were calculated when all variables were nonmissing ie that test2 above is nonmissing only at row 1.
Is this "almost a bug"? Or is it something for the wishlist?
An extra missingOne option could be a solution?
Comment