Name: Angela Spackman
About Angela: Angela worked in the market research industry for seven years in Chicago using SPSS market research software. She has worked with SPSS as a training and education consultant since February 2000. She has a BA from Western Illinois University and enjoys cooking and spending time with friends in her spare time.
Easily add complex logic to mrInterview™ surveys
The script library in the "Build Activity" section of mrInterview is an under-utilized piece of functionality. It enables anyone using “Build Activity” to add complex logic to a survey. In addition, the script library allows the advanced scriptwriter to examine good examples of reuseable code and use them in scripted surveys.
In order to use the script library items and review what is available, insert a new item in “Build Activity” and choose "Routing Items" as shown below.
Figure 1: Here’s how to insert a routing item in “Build Activity."
After you’ve inserted the item, the following dialog box will appear:
Figure 2: Choose which script items you wish to insert.
(Click to enlarge)
You can scroll through the titles of the script items and also review the full descriptions in the bottom panel as you review the choices. Each script item has a description of the item, followed by detailed step-by-step instructions on how to use this code in a survey. Simply follow the steps to add the functionality to your own survey.
If you use Dimensions™ Scripting language to create surveys without "Build Activity," the code listed at the bottom of the dialog box is the code you could use in your own surveys. You may notice that some scripting functionality has been rewritten into more robust and reusable functions that can be referenced by different types of questions in your script. Another option is adding your own code to the script library (see the Dimensions Development Library for details on how to add your script item to the script library).
Figure 3: This shows the code for the script library item.
(Click to enlarge)
You can use a script library item to initialize responses to a question. Having a value appear in the response box also makes it easier for survey respondents. In the numeric grid below, for example, respondents need to enter a response in each box before continuing with the survey—even if they don’t have anyone in these specific age groups living in their households.
Figure 4: This numeric grid lacks initialized responses.
(Click to enlarge)
To initialize the responses in this grid to "0," insert a script library item as shown above in Figures 1 and 2. Place the script item above the numeric grid. Then follow the steps written, and change the line shown below to include the name of your grid question (ages) and the value (0) to which you wish to initialize the question. Instructions also describe how to set initial values for other types of questions, such as categorical or text questions.
Figure 5: Make changes to the script library item.
(Click to enlarge)
Finally, re-activate your survey to view the results.
Figure 6: This numeric grid shows responses initialized to zero.
(Click to enlarge)
As you have seen above, the script library item allows you to add additional functionality to your surveys. Whether you’re just starting to use "Build Activity" or you’re an advanced scripter who wants to add subroutines to your scripts, the script library can be very useful.
We offer SPSS courses at locations around the world.
Find a course in the location nearest to you.
Predictive Analytics
can make your organization
more
successful
Resources