In this article
There may come a time when your survey includes a question with many answer alternatives, that you wish to simplify for your report. For example, you could have a Single question where you have asked the respondent to state their age. The answer options for the question could be the age groups "Under 18", "18 to 30", "31 to 40", "41 to 50" etc, but for the report you may wish to have just two age groups; "Up to 40" and "Over 40".
Regrouping the answers is called Recoding. You can achieve this by adding a special question to the survey, then taking the replies from the original question and collecting the answers into the required groups. This special question will be hidden from the respondent.
Note: Grid and 3D-Grid questions cannot be set to “Recoded Variable”. However, you can recode Grid data if you set up a question as a recoded variable and then recode the Grid question data into that recoded variable.
Recoding a Question
This topic contains a step-by-step example of how you recode a Single question using the Expression Builder functionality. The procedure for other types of questions is the same, though the functions available in the Expression column may differ.
In this example, assume you have the following answers in your Age question - :
Under 18 (code 1)
18 to 25 (code 2)
26 to 35 (code 3)
36 to 45 (code 4)
46 to 55 (code 5)
Over 55 (code 6)
Figure 1 - The original answers
And you would like to recode these to "Up to 35" (codes 1, 2 and 3) and "Over 35" (codes 4, 5 and 6).
To recode the question:
- Open the survey containing the question you wish to recode.
- Add a Single question to the survey after the question you wish to recode, and give the new question a logical name.
The new "Recoding" question
- For the recoding question, add the answer alternatives Up to 40 and Over 40 and set the Type field to Recoded.
- For "Up to 40" you can say "if age is code 1 or if age is code 2 or if age is code 3", and then do the same thing for "Over 40" using codes 4, 5 and 6.
- For "Up to 40" you can say "if age is less than or equal to code 3" and for "Over 40", "if age is greater than or equal to code 4".
- Click in the Expression field for the first recoded answer and type in the script to accumulate the first three answers.
- Create the expression for the "Over 40" answer in the same way.
Figure 2 - The question details page for the recoding question
Note that when you set Type to Recoded, the Question details page changes; the options and properties change, and in the Answers list several of the columns are removed and the Expression column appears.
You must now add expressions to the fields in the Expression column. These expressions must be programmed as Boolean, evaluating to true or false.
Tip:
When basing a variable on another specific question, you can use the Expression Builder to assist you with creating the expressions.
You now have several options for creating the expressions:
Figure 3 - Adding the first expression
Figure 4 -The result
After you have launched the survey, the Recoded question will be available for use in your reports. Note that the question will not be populated until a "Calculate Variables" task has been run. This task can currently only be run from the Professional Authoring application; iIn Professional Authoring, go to Reporting > Calculate Variables.