Changing the order of loop control list items
You can vary the order in which the loop control items are selected using statements in either the metadata or the routing section. Specifications in the metadata section apply to all interviews whereas specifications in the routing section may be tailored according to the respondent or type of interview (for example, do not randomize in test interviews).
In the metadata section
You can control the order of items in the loop control list by placing any of the following keywords at the end of the list, as you do with standard categorical questions:
asc
Select items in ascending order, for example, A to Z.
desc
Present items in descending order, for example, Z to A.
ran
Select items in a random order.
rev
Reverse the order of the items in the list for alternate interviews. Items are selected in reverse order for the first, third, fifth, and so on, interviews and in the defined order for other interviews.
rot
Rotate items so that each interview starts at a different position in the list while keeping the items in the same order overall.
Example
In the following example, the columns for insurance types will be presented in a random order for each interview:
InsuranceType "" define
{
Car, Health, Buildings, Contents, Travel
};
UsedBroker "For the following types of insurance, how often
do you use the services of a specialist broker?" loop
{
use InsuranceType
} ran fields (
InsuranceBroker "" categorical [1..1]
{
AllTime "All the time",
Mostly "More often than not",
Sometimes, Never
};
) expand;
In the routing section
In the routing section you specify the order for the items in the loop control list usingIQuestion.QuestionOrder. Type:
Loopname.QuestionOrder = OrderConstants.order
where order is one of:
Value
|
Action
|
oAscending
|
Sort items in ascending order. Normally used only with categorical values.
|
oCustom
|
Sort items as defined by the question’s Category.Filter property. Use when you want a customized order that cannot be achieved using the standard ordering keywords.
|
oDescending
|
Sort items in descending order. Normally used only with categorical values.
|
oRandomize
|
Sort items in a random order.
|
oReverse
|
Reverse the order of items between respondents.
|
oRotate
|
Rotate items in the loop control list.
|
For example, to sort the list of insurance types in the previous example in rotation you would type:
UsedBroker.QuestionOrder = OrderConstants.oRotate
If you want to select items in an order that is not covered by the standard options you can specify the order using the question’s Category.Filter property and then apply it using the oCustom setting. As an example, here’s a variation of the earlier script. The loop is defined as:
InsuranceType "" define
{
Car, Health, Buildings, Contents, Travel
};
UsedBroker "For the following types of insurance, how often
do you use the services of a specialist broker?" loop
{
AllTime "All the time",
Mostly "More often than not",
Sometimes, Never
} fields (
InsuranceBroker "" categorical [1..1]
{
use InsuranceType
};
) expand;
but for some respondents we want to ask about insurance in the following order: buildings, contents, travel, car, and health. There is no option that provides this automatically so we must specify the order ourselves as follows:
UsedBroker[..].InsuranceBroker.Categories.Filter = _
{Buildings, Contents, Travel, Car, Health}
and then apply it for the appropriate respondents using:
UsedBroker[..].InsuranceBroker.Categories.Order = OrderConstants.oCustom
Points to remember when altering the order in the Routing section
▪If you specify ordering for a loop in both the metadata and the routing section, the routing specification overrides the metadata specification.
▪When a loop is displayed as a grid, the questions and categories must be the same for all repetitions. You may change the order of the loop control items for the grid as long as you use the same order for each iteration. In other words, do not use the oCustom setting to specify different orders for different iterations.
▪If a loop is re-asked, the interviewing program uses the same ordering each time. The only time this changes is if the script defines a different order property for the replay.
▪Loops can be nested: that is, a loop can contain other loops. When you define ordering for a loop that contains other loops, the ordering applies only to the loop named on the ordering statement; it does not apply to loops nested within that loop. If you want to reorder the questions within a loop you must write a separate statement to do this. See
Loops inside loops for further information about nested loops.
▪If the order of responses in a row or column of a grid differs from the order of those responses in the header row or column, the interviewing program does not display the grid. Instead, it displays an error message and writes that message to the IVW* log file. This prevents data corruption that would happen if the script was allowed to run as written. A simple way to avoid this error is always to specify rotation or randomization for loops in the metadata section of the script, as this ensures that all iterations of the loop will use the same rotation or randomization pattern. If you have to specify rotation or randomization in the routing section, you should always set the program’s state before requesting the reordering. For example, always set the randomization seed before requesting randomization, as shown here:
For Each Question In MyLoop
SetRandomSeed(IOM.Info.RandomSeed)
Question.Order = OrderConstants.oRandomize
Next
See also