Hello you can try this:
* create sample data *.
INPUT PROGRAM.
NUMERIC state (F2).
LEAVE state .
LOOP K = 1 TO 2000.
COMPUTE state =rnd(1* RV.uniform(1, 50)).
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.
do repeat a = 1 to 50/
b = state1 to state50.
if (state = a) b = 1.
end repeat.
do repeat a = p1 to p20.
COMPUTE a =rnd(1* RV.uniform(0, 1)).
end repeat.
save outfile = myfile.
get file = myfile.
* aggreate for each state *.
AGGREGATE
/OUTFILE=*
/BREAK=state1
/ p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20=SUM(p1 to p20) .
select if (~sysmis(state1)).
you may need a macro to do this for state1 state2 ... state50
then rename state 1 , ... state50 to state, and add all files to one file,
regards,
------------------------------
xiaoqin Oezener-Wan
------------------------------
Original Message:
Sent: Sat September 18, 2021 02:04 PM
From: Nathanael Sovitzky
Subject: Multiple Response on one Question
Hello.
For my project, we are working on a survey that was conducted nation wide. We had a question in which respondents identified their state of residence. That was one question whose answers were 1-50. Each number corresponded to one of the 50 states. We also had another question where we asked the respondents to identify a group of about 20 pollutants. Respondents were told to select all the pollutants they knew about. This generated two variables, with a one or zero (one: aware of the pollutant, zero: unaware of the pollutant).
We now want to look at the data state by state. How would I go about setting up a crosstab where I can look at each state in one row, and the twenty contaminants in the columns, so that we can identify the most well known contaminants per state.
Thank you for your help.
------------------------------
Nathanael Sovitzky
------------------------------
#SPSSStatistics