Screening based on a large list of ZIP codes

In a previous study, we wanted to only allow respondents to continue if they were from a ZIP code among a list of ZIP codes. I found another forum post (https://sawtoothsoftware.com/forum/14004/zip-code-screening) that was helpful and I used this code:


Begin Unverified Perl

my $i=1;

for($i=1; $i<=LISTLENGTH("zipList1"); $i++)
{
if (VALUE("Zip") eq LISTLABEL("zipList1",$i))
{
ADD("zipList1",$i);
last;
}
}

End Unverified


This worked well except that our list had more than 1,000 ZIP codes and if a respondent entered a ZIP that was not on the list, it had to check every single ZIP in the list which could take up to 30 seconds in testing. Has anyone found a more efficient way to screen respondents based on a large list of ZIPs.

Also, the ZIPs are more or less random, so you cannot rely on patterns in the ZIP to make the search more efficient.

Resolved
4 replies