# RE: st: RE: Creating a Count Variable

 From "Nick Cox" To Subject RE: st: RE: Creating a Count Variable Date Fri, 4 Apr 2008 17:14:08 +0100

```This territory is often called "multiple responses".

. search multiple responses

in Stata yields (e.g.)

FAQ     . . . . . . . . . . . . . . . . . . .  Dealing with multiple responses
. . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox and U. Kohler
4/05    How do I deal with multiple responses?
http://www.stata.com/support/faqs/data/multresp.html

SJ-5-1  st0082  . . . . . . . . . . . . . . . Tabulation of multiple responses
(help _mrsvmat, mrgraph, mrtab if installed)  . . . . . . . .  B. Jann
Q1/05   SJ 5(1):92--122
introduces new commands for the computation of one- and
two-way tables of multiple responses

SJ-3-1  pr0008   Speaking Stata: On structure & shape: the case of mult. resp.
. . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox & U. Kohler
Q1/03   SJ 3(1):81--99                                   (no commands)
discussion of data manipulations for multiple response data

Nick
n.j.cox@durham.ac.uk

Friedrich Huebler

Assuming that Isaac is correct and the variables are indeed coded as 0
and 1, the -gen- command in his message only yields the sum of
selected responses if there are no missing values across the response
variables. With -egen rowtotal- missing values are treated as 0.

. egen newvar = rowtotal(vara varb varc vard vare)

Vargas Naranjo Isaac Alonso

> Puede hacerlo de la siguiente manera:
>
>  Gen newvar=vara+varb+varc+vard+vare
>
>  Le generará una nueva variable con la suma de las otras que me imagino deben estar codificadas como 0 y/o 1, el resultado será la suma de veces que fue seleccionado algún elemento.

Chao Yawo

>  I have a range of 5 variables that ask respondents
>  who is responsible for different household household
>  tasks (vara, varb, varc, vard, vare). Respondents
>  have a choice of selecting one fo the followinvg
>  responses/values for each question:
>
>  1. Respondent Alone,
>  2. Respondent and Roomate
>  3. Respondent and Someone else
>  4.Roomate Alone
>  5. Someone else alone.
>
>  I want to create a variable that counts how many
>  times a respondent selects each of these
>  values/responses/choices across all the five
>  variables (vara - vare).
>
>  The resulting output would list per respondent, how
>  many times they selected each choice (across the 5
>  variables).

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