Professional > Interview scripting > Writing interview scripts > Logical expressions > Checking categorical responses > A given number of specified responses chosen
 
A given number of specified responses chosen
To test whether the respondent chose a given number of answers from a set of responses, as in, did the respondent choose three track and field sports from a selection of sports, use the ContainsSome function.
Syntax
ContainsSome({Resp1, Resp2, ... Respn}[, Minimum][, Maximum][, No_Others])
Parameters
Qname
The name of the question whose response you want to check.
Resp1 to Respn
The names of the responses you want to check for.
Minimum
The minimum number of responses that must be chosen from the set in order for ContainsSome to be True. If you omit this parameter, the default is zero meaning that none of the specified responses need be chosen.
Maximum
The maximum number of responses that must be chosen from the set in order for ContainsSome to be True. If you omit this parameter, the default is the number of responses specified in the expression.
No_Others
No_Others is True if the response may contain only answers from the specified set, or False if other answers may be chosen too. The default is False.See ContainsSome for more information.
Example
If the Sports question is defined in the Metadata section as:
Sports "Which sports do you take part in?" categorical [1..]
{
  Running, Cycling, Football, Javelin, Discus,
  HighJump "High jump", LongJump "Long jump",
  Swimming, Basketball, Tennis, Hockey, Rugby,
  PoleVault "Pole vault", Netball, Gymnastics
};
and you want to test whether the respondent’s answer contains between three and five track and field events, you would write the following expression:
Sports.ContainsSome({Running,Javelin,Discus,HighJump,LongJump,
    PoleVault}, 3, 5)
This expression ignores any other sports that may be present in the response to the Sports question, and has the same effect as:
Sports.ContainsSome({Running,Javelin,Discus,HighJump,LongJump,
    PoleVault}, 3, 5, false)
If you want to take other sports into account and test whether the respondent mentioned only three, four, or five track and field events and no other sports, you would write:
Sports.ContainsSome({Running,Javelin,Discus,HighJump,LongJump,
    PoleVault}, 3, 5, true)
You can leave the minimum and/or maximum number of required responses undefined, and the interviewing program will use the function’s default settings instead. The default minimum is one, so the expression:
Sports.ContainsSome({Running,Javelin,Discus,HighJump,LongJump,
    PoleVault}, 5)
is True if the respondent’s answer contains between one and five of the specified sports. It is False if all six sports or none are mentioned. The results of the expression are unaffected by any other sports mentioned.
Similarly, if the expression is:
Sports.ContainsSome({Running,Javelin,Discus,HighJump,LongJump,
    PoleVault}, 3)
the result is True if the respondent mentions at least three of the specified sports, regardless of any other sports mentioned.
See also
Checking categorical responses