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

st: multiple response to binary


From   Lee Sieswerda <[email protected]>
To   "Statalist (E-mail)" <[email protected]>
Subject   st: multiple response to binary
Date   Fri, 12 Jul 2002 12:34:46 -0400

Hello all:
I have a data management problem (WinNT4, Stata v7).

I have data from a questionnaire where some of the questions allow the
respondent to choose multiple responses. Lets say there 7 possible responses
and they could choose any number of them. I would code this as a set of 7
binary variables. Unfortunately, the way it was coded was not so
straightforward. It was coded across 7 variables, but the responses were
simply entered in the order in which they were given by the respondent. So
the data look like this:

f4m1      f4m2      f4m3      f4m4      f4m5      f4m6      f4m7
    1         7         4         .         .         .         .
    1         .         .         .         .         .         .
    1         .         .         .         .         .         .
    1         .         .         .         .         .         .
    7         3         .         .         .         .         .
    1         .         .         .         .         .         .
    1         2         3         4         .         .         .
    1         2         3         4         6         .         .
    1         2         7         .         .         .         .
    1         .         .         .         .         .         .

As you can see, you cannot simply tabulate the number of people who
responded 1, 2 , 3 etc because the responses are scattered over the 7
variables in a different order for every person. The folks who provided me
with this data use SPSS and they get around this problem by using "multiple
responses sets". In SPSS, you can define a set of variables as a multiple
response set (in this case, seven variables) and then ask for tables of
frequencies and crosstabs generated from across the 7 variables. It works,
but I'd much rather use Stata than SPSS. Also, the SPSS solution is limited
to simple tables and doesn't permit you to get chi-square or other
statistics.

Now, in Stata I know I can generate dummy variables from this mess like
this:
gen dum1 = 0
replace dum1 = 1 if f4m1==1 | f4m2==1 | f4m3==1 etc.
replace dum1 = . if f4m1==. & f4m2==. & f4m3==. etc.
gen dum2 = 0
etc.

However, this is tedious in the extreme and there are many of these multiple
response questions in the dataset. I could automate the procedure somewhat
using -foreach-, but its still more brute force than elegance. Someone told
me about a SAS solution to this problem using an array procedure. Does
anyone have a nice elegant Stata solution to this problem?

Thanks,

Lee

Lee Sieswerda, Epidemiologist
Thunder Bay District Health Unit
999 Balmoral Street
Thunder Bay, Ontario
Canada  P7B 6E7
Tel: +1 (807) 625-5957
Fax: +1 (807) 623-2369
[email protected]
www.tbdhu.com

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