NIPO ODIN Version 5.17

*ORDER

Purpose

Set the order of codes in a code list or the order of execution in a *REPEAT loop.

Syntax

*ORDER <var | QnM | QnR>

Description

You can define the order of codes in a *CODES or *FORM question and the order of a *REPEAT loop according to the contents of an array variable or the order of mentions of another question.

  • Both variable names and questions with order specifier (QnM or QnR) may be used in the *ORDER command.
  • *ORDER may be used in a *REPEAT, *QUESTION or *FORM statement.
  • Invalid orders in the argument with *ORDER are ignored. This means if an order number is used twice or if an index in the variable is empty, all remaining code are displayed in regular ascending order.
  • *ORDER cannot be used together with *RANDOM, *INV or *ROT.
  • The order of mentions in a question are available through QnMi where n is the question number and i is the index of the mention.
  • The display order of a random-question is available through QnRi, where n is the question number and i is the index of the random order.
  • You can store the order of mentions and or the random order by specifying a length behind the *MULTI or *RANDOM command using Ln where n is the number of positions to store answers. The operators QnM and QnR are available, independent of whether the order is saved or not.
  • A syntax check produces a warning message if the variables M or R are defined. If these variable names are used, the operator QnMi and QnRi are not available.
  • The items in a *REPEAT block or code list which are not in the *ORDER command, are displayed in the order as if there was no *CONTROL command. This means that if you only want to show the items mentioned in a previous *CODES question in the order they were mentioned, you have to use both a *ORDER and a *CONTROL command.

Arguments

var
This is a variable name of an array variable (*VARS name[n]). The values in this variable set the order in which the codes are displayed or the order in which the *REPEAT loop is processed.

QnM
This is order of mentions of a previous *MULTI question.

QnR
This is the order in which a previous question with *RANDOM, *INV or *ROT was displayed.

Example 1

*QUESTION 1 *CODES 61L5 *MULTI 66L4
Which brands do you know?

(Int. do NOT help!

Type the answers in the same order as given by the respondent)

1: brand A
2: brand B
3: brand C
4: brand D

5: None of these *NMUL *NOCON

*QUESTION 2 *CODES 71L5 *MULTI 76L4 *CONTROL Q1 W *ORDER Q1M
Which brand do you use most often

(Brands are presented in the order that was entered in Q1)

1: brand A
2: brand B
3: brand C
4: brand D

5: None of these *NMUL *NOCON

Example 2

*QUESTION 3 *CODES 81L5 *MULTI *RANDOM
Which of the following brands do you know?

1: brand A
2: brand B
3: brand C
4: brand D

5: None of these *NMUL *NOCON

*TEXTVARS STATEMENT
*REPEAT 5 *ORDER Q3R

** The repeat loop will be executed in the same order
** that Q3 was (randomly) displayed

*REPNUM 1 *PUT STATEMENT "Brand A"
*REPNUM 2 *PUT STATEMENT "Brand B"
*REPNUM 3 *PUT STATEMENT "Brand C"
*REPNUM 4 *PUT STATEMENT "Brand D"
*REPNUM 5 *PUT STATEMENT "All brands"

*QUESTION 4 *CODES L1
*?STATEMENT

5: 5 (good)
4: 4
3: 3
2: 2
1: 1 (poor)

*ENDREP

Example 3

*** 'Brand A' should always be presented first
*** 'Brand B', 'Brand C' and 'Brand D' should be in random order
*** 'All brands' should always be last

*VARS MyOwnOrder[4],NR
*PUT MyOwnOrder[1] [1]

*** Create an extra repeat-loop to get 3 unique numbers
*** 2 through 4

*REPEAT 3 *RANDOM
*PUT NR [ NR + 1 ]
*PUT MyOwnOrder[?R + 1] [NR + 1]
*ENDREP

*TEXTVARS STATEMENT

*REPEAT 5 *ORDER MyOwnOrder

** The repeat loop will be executed in the order
** that I defined in the variable MyOwnOrder
** As the variable MyOwnOrder has only 4 indices,
** the fifth repetition will be executed in the normal order
** (i.e. last)

*REPNUM 1 *PUT STATEMENT "Brand A"
*REPNUM 2 *PUT STATEMENT "Brand B"
*REPNUM 3 *PUT STATEMENT "Brand C"
*REPNUM 4 *PUT STATEMENT "Brand D"
*REPNUM 5 *PUT STATEMENT "All brands"

*QUESTION 3 *CODES L1
*?STATEMENT

5: 5 (good)
4: 4
3: 3
2: 2
1: 1 (poor)

*ENDREP

When you create random order numbers for brand A, B, C and D, you could also use the RAN operator. But then you are not sure that it will pick four different numbers. If this happens, brand A, B, C and D will be in random order until a duplicate is met.

*PUT MyOwnOrder[1] [ (RAN 4) + 1 ]
*PUT MyOwnOrder[2] [ (RAN 4) + 1 ]
*PUT MyOwnOrder[3] [ (RAN 4) + 1 ]
*PUT MyOwnOrder[4] [ (RAN 4) + 1 ]

*REPEAT 4 *ORDER MyOwnOrder

See Also