Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: how to cope with missings in my case


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: how to cope with missings in my case
Date   Fri, 7 Oct 2005 15:13:48 +0200

Xiangping JIA wants to add some variables, but when one is missing the
sum becomes missing.

This is standard behavior. However, egen's rowtotal() function does the
trick (in Stata 8 the name is rsum().

clear
input index var1 var2 var3
  1  .  1  1
  2  1  1  .
  3  .  1  1
end
generate var4=var1+var2+var3
egen var5=rowtotal(var1-var3)

. list

      +------------------------------------------+
      | index   var1   var2   var3   var4   var5 |
      |------------------------------------------|
   1. |     1      .      1      1      .      2 |
   2. |     2      1      1      .      .      2 |
   3. |     3      .      1      1      .      2 |
      +------------------------------------------+

Hope this helps
Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: sj@soci.au.dk
__________________________________________

*
*   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/



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