Have an idea?

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

SETVALUE using Perl hash

I am looking to assign a weight to respondents from particular zip codes for my study. I am trying to use a perl hash to lookup the weight value needed and save it in the free format variable I have called "ZipAdjustment_weight" - actual zips are captured in the value S25. I need to save as a variable in the study to do a calculation with a later response.

Similar to question asked here, and I got this to work to return the value:


I just can't get this value to be stored in a variable - Thoughts?

[%Begin Unverified Perl
my $zipCodeQuestion = 'S25';
my %zipCodes = (
    12345 => 0.88,
    12344 => 0.97,
    12356 => 0.97,
    12332 => 0.88
SETVALUE("ZipAdjustment_weight", $zipCodes{GETVALUE($zipCodeQuestion)};
End Unverified%]
asked Oct 14, 2021 by Leslie (220 points)
You are missing a closing parenthesis before the final semicolon.    Add that and see if you get the behavior you want.
that's it, thanks as always!

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.