How To Convert Binary Variables Into Max-Multi Format
From Q
To convert data from a binary to max-multi format:
- In the Variables and Questions tab, right-click and select Insert Variable(s) > JavaScript Formula > Numeric.
- Fill in as follows:
- Name: mm1
- Label: Variable 1
- Expression: Enter the expression below, but replacing the list of variable names in the second row with the list of your binary variables' names.
- Press OK.
- Right-click on the variable that has just been created and select Copy and Paste Variable(s) > Exact Copy.
- Right-click on the new variable and select Edit Variable.
- Replace the number 1 in each of the Name, Label and first line of the Expression with a 2.
- Press OK.
- Keep repeating the previous four steps, adding 1 each time, until the Mean shown at the bottom-right corner of the dialog box becomes NaN. At this point, you have all the max-multi variables required to represent the binary data.
Expression
var number = 1; var variables = [q5_1,q5_2,q5_3,q5_4,q5_5]; function getAllIndexes(arr, val) { var indexes = [], i = -1; while ((i = arr.indexOf(val, i+1)) != -1){ indexes.push(i); } return indexes; } getAllIndexes(variables, 1)[number - 1] + 1