Compute
Creating Global Variables
Example - Using compute to sum scored questions for use elsewhere in the survey.
A researcher plans to ask the following two questions and then wants to ask a further question based on the total amount or reading the respondent has done either by reading electronic books or regular books. To do this the programmer needs to create a global value and add the two scores together from the two questions.
Now we want to add the two totals 'Reading a book' and 'Reading an e-book' together.
To do this we use a 'Compute' question type.
1. The first step - create a new question type and select the 'Compute' option in the usual way and give this new question type a name - in this case "Read_Tot".
2., Create the global variable that will hold the computed variable.
To do this click on the 'Creat global variable' icon circled below or press the 'global variable' icon from the top menu.
Pressing this icon results in a popup appearing that is used to build a global variable.
In the textbox next to 'Name' type the name of your variable - in this case R_Tot is being created. Pressing the "Add" icon will add the global variable to the list of available variables.
The variable is now available for selection and the two answers can now be added together to produce its score for the survey.
Select the new variable from th edrop down and begin to define your formula by pressing the 'Select Question; button.
First add the first answer "Q5. Reading an electronic book" by pressing the "Select Question" button. A pop up (shown below) will appear showing you only the questions that can be used for calculating global values (Scored question types).
Select Q5 and the answers to Q5 will appear. Select the answer you wish to use for the formula - in this case "Reading an electronic book".
NOTE: It is also possible to choose the TOTAL of all the answers for this question. This is useful for instance if you wish to use the total amount of time spent on all these activities at a latter part of the survey.
Your Compute question will at this point look like the following.
The value of R_Tot is now + "Q5. Reading an electronic book" answer value.
Next we need to add the normal reading time to this variable. Press the + button (shown circled above) to include another condition.
Now press the "Select Question" and choose the next answer that you wish to add to the global variable - Q7.Reading a book, in the same way that you selected the previous answer. The parameters of this compute question will now look like this.
Both of these answers will now be added together and available for use in other parts of the survey such as embedding into question texts suck as;
"Thinking about the [R_Tot] hours you have spent reading what...,"
which will appear as,
"Thinking about the 12 hours you have spent reading what...,"
or using as input into other question parameters such as a scored questions required total (shown circled below).
NOTE: There are four arithmetic conditions available, addition, subtraction, division and multiplication.