Bookmark and Share

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

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

Re: st: Combining variables without adding

From   Cory Smith <>
Subject   Re: st: Combining variables without adding
Date   Wed, 23 Nov 2011 19:05:46 -0500

check out -rownonmiss- under egen. You could do

egen numAns = rownonmiss(peaches*) . This will count the number of
answers someone gave to peaches* questions (i.e. the number of

This will let you focus on the set where people answered correctly.
You'll have to pick how you want to deal with the people who answered


On Wed, Nov 23, 2011 at 6:53 PM, Jessica Kopsic <> wrote:
> Hello all,
> I am using Stata 12.0.
> I have questions in a dataset answered with a Likert-type scale. The data
> is currently arranged so that each answer to each question is its own
> variable. So if the question is "Do you like peaches?" Then Peaches1 is a
> variable, Peaches2 is a variable, and so on. If the person selected one,
> there would be a 1 for the Peaches1 variable and the remaining Peaches
> variables would be blank. I would like to combine all the Peaches
> variables so that there is only one variable for response to the Peaches
> question, with possible values from 1 to 5.
> The complicating factor is that it was possible for people to erroneously
> select more than one answer. So if someone marked 1 and 4, they would have
> a value for Peaches1 and a value for Peaches4. If I simply added all the
> Peaches variables together, it would give them a 5, which is not correct.
> How can I avoid this? For some cases of more than one response I would
> like to use the mean, in others I would like to use the lowest response.
> Thank you!
> *
> *   For searches and help try:
> *
> *
> *

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index