For this worked example, we are using data from a tracking study on cola consumption habits. We have consumption data on six types of colas — Coca-Cola, Diet Coke, Coke Zero, etc — and we want to determine the most-consumed beverage for each survey respondent.
The first step is to create a new variable. In the Variables and Questions tab, right-click anywhere within the window and
var x = [q2b_1, q2b_2, q2b_3, q2b_4, q2b_5, q2b_6]
max = Math.max(q2b_1, q2b_2, q2b_3, q2b_4, q2b_5, q2b_6)
- Line 1 creates an array of the variables we want to analyze.
- Line 2 finds the largest of the given values.
- Line 3 locates the position of the largest value.
Step 3: Change the question type of the new variable
In the Variables and Questions tab, change the Question Type to Pick One. This will allow you to analyze the question as a categorical variable rather than a numeric variable.
Article is closed for comments.