Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: RE: newvar adding scores with missing values


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
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: [email protected]
[mailto:[email protected]] On Behalf Of STEVEN HARVEY
Sent: Mittwoch, 12. Mai 2010 19:08
To: [email protected]
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


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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index