Filtering the repetitions of loops with categorical control lists
Filtering the repetitions of a loop with a categorical control list is similar to filtering an ordinary categorical response list. You define the loop so that its control list contains all possible categories, and then add routing statements that specify for which categories the loop should be executed.
Syntax
In the routing section, type:
<name>.Categories.Filter = {<categories>}
Parameters
<name>
The name of the loop.
<categories>
The categories to be displayed. This can be the name of a single category or a comma-separated list of category names, both enclosed in { } braces. You can specify a range of categories by using the standard range syntax: see
Category expressions.
Example
Here is an example based on a loop that is defined in the metadata section as follows:
FoodList define
{
Fruit, Vegetables, Salads, Fish, Meat, Bread,
Dairy "Dairy produce",
Pulses "Pulses/Nuts/Cereals",
PastaRice "Pasta/Rice"
};
TimesEaten "On the following days last week, how many times did you
eat ... ?" loop
{use FoodList}
fields
(
Monday long [0..10];
Tuesday long [0..10];
Wednesday long [0..10];
Thursday long [0..10];
Friday long [0..10];
Saturday long [0..10];
Sunday long [0..10];
) grid expand;
To ask about pulses/nuts/cereals, pasta/rice and bread only, put the following statement in the routing section before the loop:
TimesEaten.Categories.Filter = {Pulses, PastaRice, Bread}
TimesEaten.Ask()
If the categories to be used as filters are defined consecutively, you can save yourself work by using the double-dot range operator. For example:
TimesEaten.Categories.Filter = "Fruit..Bread"
Another way of filtering loop repetitions is to use the QuestionFilter object with a simple reference to the loop name:
TimesEaten.QuestionFilter = {Fruit, Salads}
This produces a grid with rows for fruit and salads only and columns for all days of the week. Because there is no [..] qualifier specified for the loop name (TimesEaten), the interviewing program assumes that the filter applies to the repetitions of the loop rather than the questions.
See also