[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: generate sum of variables & ignore missing

From   Richard Goldstein <>
Subject   Re: st: generate sum of variables & ignore missing
Date   Thu, 05 Jun 2008 08:34:42 -0400

use egen with the rowtotal option; e.g.

egen varD=rowtotal(varA varB varC)


Andrea Bennett wrote:

I guess this is an easy task for somebody more experienced. I have 3 columns (varA, varB, varC) containing dummy variables (0, 1, missing values "."). I would like to generate "varD" the sum of each row, e.g. if varA==1 varB==0 varC==1 I should have varD==2. This works clearly fine when there are no missing values (varD= varA + varB + varC). But is there an easy way to let Stata read a missing value as "0" so that varA==1 varB==. varC==1 would result in varD==2 (without actually replacing the missing values with "0")? I am trying to get it to work with -missing()- but so far have not succeeded.

Many thanks for your consideration,

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index