Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: newvar adding scores with missing values


From   STEVEN HARVEY <SHARVEY@URC-CHS.COM>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: newvar adding scores with missing values
Date   Wed, 12 May 2010 13:07:31 -0400

I am working in Stata 10 on panel data with 3 waves. I want to generate a variable equal to the total sum of incorrect answers per individual across waves. I have variables with number of incorrect answers in each wave - for sake of argument, call them w1, w2, and w3. Since not all participants were present for all three waves, some values in each of these variables are system missing ("."). If I generate a variable adding the values from each wave (wtot = w1 + w2 + w3), Stata assigns "missing" as the value if any one of the three variables contain a missing value: 

Case      w1          w2          w3          wtot
  1        1           0           2            3
  2        0           1           0            1
  3        0           0           0            0
  4        1           .           2            .

I need to know the total number of incorrect answers across all three waves even if the participant was not present for all three. How can I get Stata to return the sum of each wave in which the participant was present?

Case      w1          w2          w3          wtot
  1        1           0           2            3
  2        0           1           0            1
  3        0           0           0            0
  4        1           .           2            3


My apologies in advance to those who may have already answered a similar question or consider it too simple. It does seem simple, but I have searched through [U], [D], the on-line help within Stata, and the Statalist FAQs and archive and have not found an answer.

Many thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Steven A. Harvey, Ph.D.
Senior Malaria Advisor
University Research Co., LLC / Center for Human Services
7200 Wisconsin Avenue, Suite 600
Bethesda, MD 20814
USA
 
Tel.: +301-941-8441
Fax: +301-941-8427
 
www.urc-chs.com

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index