Have an idea?

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

Begin Unverified Perl with AIC

Here is what I want to do...

I have a list called S8 - Items in this list are

String Cheese
Sausage
Cheese
Shredded Cheese
Tortilla
Singles
None

In S8, it asks, which of the following do you buy? I only show the list from 2 through 7 (multiple choice)

If they select Cheese, they are asked S9 -What is your likelihood to buy string cheese... They rate this from 5,4,3,2,1  - If they rate a 5 or 4, they are considered a String Cheese buyer

So, I now need to bring these answers forward into the question called Invite. I've created a new list called NewList

I only want to bring forward the choices in S8 of Cheese (position 3), Shredded Cheese (position 4) and Singles (position 6) if they select them, BUT also bring forward String Cheese (from the 1st position in S8List) if they rated S9 a 4 or a 5.

I'm struggling with this because the S9 question is ONLY asked if the respondent selects Cheese - if they don't, they skip S9.  How do I do this? I’m using the AIC format plus perl. It’s currently pulling in String Cheese into the Invite question if the respondent is not asked, I somehow have to factor out the null response…

Here is what I have thus far...

AIC (S8)

Begin Unverified Perl
if (VALUE("S9") <= 2) {ADD("S8List", 1);}
End Unverified

Randomize (2, 6)
REMOVE (S8List, 2)
REMOVE (S8List, 5)

Sort of confusing - let me know if you need more info.
asked May 15 by anonymous

1 Answer

0 votes
There are a few ways you can do this.

1. The Sawtooth Script function Shown should return whether or not a given question was shown to the respondent:

if (SHOWN("S9") && VALUE("S9") <= 2) {
    ADD("S8List", 1);
}


2. I believe the Value function will return zero when the question is skipped.  So you could rework the logic to be something like this:

my $s9 = VALUE("S9");
if ($s9 == 1 || $s9 == 2) {
    ADD("S8List", 1);
}
answered May 15 by Zachary Platinum Sawtooth Software, Inc. (121,725 points)
...