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

Re: st: Number of right answers


From   "Oleksandr Talavera, BC" <[email protected]>
To   [email protected]
Subject   Re: st: Number of right answers
Date   Tue, 28 Jan 2003 20:58:27 -0500

Please try the following:
*----------------------
g correct = 0
* list with correct answer 1
local 1correct n15a n15d
* list with correct answer 2
local 2correct n15b n15c
* you can create other locals and then change values in loop
forvalues j=1(1)2 {
   foreach i of local `j'correct {
       replace correct = correct +1 if `i'==`j'
}
}
*----------------------

Best,
Sasha

--------------------
Oleksandr Talavera
[email protected]



Jorge Mendoza A. wrote:

Dear Statalist,

In the data I have received, question 15 , for example, has been divided
into n15a....n15j (it means there are 10 vars related to a one
question), with three possible anwers each one (1,2 or 3). One of them
is correct. I would like to generate a variable that counts the number
of correct answers for each record (individual).
The data looks like:

N15a n15b n15c n15d ...... Newvar (# of correct answers)
1 2 3 1 3
1 1 2 1 3
1 2 2 1 4
2 3 1 2 0
3 2 1 3 1

As we can see the right answer is not the same for all variables, 3 is a
"don't know" answer. Thus, for question n15a, the correct answer is 1;
for n15b is 2; for n15c is 2; for n15d is 1, etc.

Can somebody help me with this?

Jorge


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



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index