Have an idea?

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

Creating a grid from a constructed list based on responses to another constructed list

I have created a grid question (Q29) Based on Responses to Q3 (Region) that will include a list of companies in Q14 (Company Names), using the following Perl Script.

Begin Unverified Perl

if (VALUE("Q3_12")==1)
 {
  ADD("Q14B",1,9);
 }
if (VALUE("Q3_10")==1)
 {
  ADD("Q14B",1,6);
 }
if (VALUE("Q3_10")==1)
 {
  ADD("Q14B",10,13);
 }
if (VALUE("Q3_4")==1)
 {
  ADD("Q14B",1,6);
 }
if (VALUE("Q3_4")==1)
 {
  ADD("Q14B",10,13);
 }
if (VALUE("Q3_5")==1)
 {
  ADD("Q14B",1,6);
 }
 if (VALUE("Q_5")==1)
 {
  ADD("Q14B",10,13)
  }
if (VALUE("Q3_8")==1)
 {
  ADD("Q14B",1,6);
 }
 if (VALUE("Q3_8")==1)
 {
  ADD("Q14B",10,13);
 }
 if (VALUE("Q3_11")==1)
 {
  ADD("Q14B",1,6);
 }
 if (VALUE("Q3_11")==1)
 {
  ADD("Q14B",10,13);
 }
 if (VALUE("Q3_2")==1)
 {
  ADD("Q14B",1,6);
 }
 if (VALUE("Q3_2")==1)
 {
  ADD("Q14B",10,13);
 }
 if (VALUE("Q3_3")==1)
 {
  ADD("Q14B",1,6);
 }
 if (VALUE("Q3_3")==1)
 {
  ADD("Q14B",10,13);
 }
 if (VALUE("Q3_9")==1)
 {
  ADD("Q14B",1,6);
 }
  if (VALUE("Q3_9")==1)
 {
  ADD("Q14B",10,13);
 }
 if (VALUE("Q3_7")==1)
 {
  ADD("Q14B",1,6);
 }
  if (VALUE("Q3_1")==1)
 {
  ADD("Q14B",1,6);
 }
  if (VALUE("Q3_6")==1)
 {
  ADD("Q14B",1,6);
 }
This script works fine.

Q29 asks familiarity with the companies. The question is a grid, with 5 columns (Current Customer/HAve used in the past/Know something About/ Know Name only/Never heard of]

I am creating a subsequent grid question (Q30) that asks for likelihood to use the company, based on the response to Q29.  I have constructed a list Q30 using the following script.

Begin Unverified Perl

If (Value "Q29,1"<=4)
{
  ADD("Q14B",1);
 }
If (Value "Q29,2"<=4)
{
  ADD("Q14B",2);
 }
 If (Value "Q29,3"<=4)
{
  ADD("Q14B",3);
 }
If (Value "Q29,4"<=4)
{
 ADD("Q14B",4);
 }
If (Value "Q29,5"<=4)
{
  ADD("Q14B",5);
 }
If (Value "Q29,6"<=4)
{
  ADD("Q14B",6);
{
  If (Value "Q29,7"<=4)
{
  ADD("Q14B",7);
 }
  If (Value "Q29,8"<=4)
{
  ADD("Q14B",8);
 }
 If (Value "Q29,9"<=4)
{
 ADD("Q14B",9);
 }
 If (Value "Q29,10"<=4)
{
  ADD("Q14B",10);
 }
 If (Value "Q29,11"<=4)
{
  ADD("Q14B",11);
 }
 If (Value "Q29,12"<=4)
{
 ADD("Q14B",12);
 }
If (Value "Q29,13"<=4)
{
  ADD("Q14B",13);
 
End Unverified

I keep getting a script error. I can't figure this one out.

Can someone tell me what I am doing wrong here?
asked Nov 18, 2013 by rickcis (175 points)
edited Nov 18, 2013 by Walter Williams

2 Answers

+5 votes
 
Best answer
Use just AIL(Q29,5)
answered Nov 18, 2013 by Saurabh Aggarwal Gold (29,615 points)
selected Dec 15, 2013 by Rajesh Rana
0 votes
Your Perl is not working because Perl is case sensitive.

"Value" should be "VALUE". Review the Sawtooth help for Perl syntax when using functions.

Also, your question names should be exactly as you defined them.

You also have missing brackets around each question name in the IF statement lines.

The final ADD command does not have a closing bracket either.

The earlier answer should work using AIL but I wanted to mention where you went wrong in your Perl programming.
answered Nov 18, 2013 by Paul Moon Platinum (65,130 points)
...