Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

How to select randomly from previous answers and store the results

I start with one question where people have to select all the relevant options in a list of 8 options:

Q1:
1
2
3
4
5
6
7
8 - others

After that, i want to randomly select 3 of the answers on Q1 (or less, if they filled in only 2 or 1 options), with a less than average chance of selecting '8 - others'. Next, I would like to   ask the respondents a couple more questions about each of the randomly selected option: Q2-Q8.

My questions are:
* how can i program that sawtooth picks three random options (with a less than average chance of option 8) and stores the results?
* how can i program Q2-Q8 efficiently? These answeroptions on Q2-Q8 are the same, independent of selecting option 1-8 of Q1. I only would like to use a dynamic aspect in the question itself, based on the answer on Q1.
asked Nov 8, 2021 by Jeroen
What is the exact criteria that is intended for selecting the eighth item?
There is no exact criteria. The option 8 is just not that relevant for the research we are conducting, but we nevertheless need some information about it. Let's say that the chance of picking option 8 should be 8 percent.

1 Answer

0 votes
I'd start by creating a constructed list with these instructions:

Begin Unverified Perl
# Params
my $selectQ = 'Q1';

# Run
my $len = 0;
for (my $i = 1; $i <= 7; $i++) {
    if (GETVALUE($selectQ . '_' . $i)) {
        ADD(PARENTLISTNAME(), $i);
        $len++
    }
}
RANDOMIZE();
LISTMAX(3);
if (GETVALUE($selectQ . '_8')) {
    if ($len < 3) {
        ADD(PARENTLISTNAME(), 8);
    }
    elsif (rand(100) < 8) {
        LISTMAX(2);
        ADD(PARENTLISTNAME(), 8);
    }
}
End Unverified


If you want to show a series of questions relating to each item chosen in this constructed list, you should add a loop to your survey.  You can set the loop to use this constructed list, then use Sawtooth Script like this in the questions to show the label of the current item to the respondent:

[% LoopLabel() %]
answered Nov 9, 2021 by Zachary Platinum Sawtooth Software, Inc. (206,100 points)
add answersoptions based on loop
Thank you! That works fine.

I have two more related questions: we decided that we want to add a few answeroptions in Q2-Q8 based on the specific item that is randomly selected and looped from Q1. So for example:

Q1: respondent selected items 1-5, and 2-4 are randomly selected

loop for item 2:
Q2:
1 - general
2- general
3- general
4 - specific item 2
4 - specific item 2

loop for item 3:
Q2:
1 - general
2- general
3- general
4 - specific item 3
4 - specific item 3

My questions:
* How can i program this?
* how can i store the results of the randomly selected items of the constructed list for each respondent?
Thanks in advance!
...