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.

# st: RE: newvar adding scores with missing values

 From "Martin Weiss" To Subject st: RE: newvar adding scores with missing values Date Wed, 12 May 2010 19:14:46 +0200

```<>

***********
clear*

inp byte(Case   w1  w2  w3)
1        1           0           2
2        0           1           0
3        0           0           0
4        1           .           2
end

egen wtot=rowtotal(w?)
l, noo
***********

HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of STEVEN HARVEY
Sent: Mittwoch, 12. Mai 2010 19:08
To: statalist@hsphsun2.harvard.edu
Subject: st: newvar adding scores with missing values

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

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

Many thanks.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
Steven A. Harvey, Ph.D.
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/

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