UCL WIKI

UCL Logo
The Wiki will be upgraded to version 6.3 in early August - exact dates will be announced shortly. Please see the 6.0 Release notes and 6.3 Release notes for info on new features.
Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Warning

This page is still under construction.

Info
titleKey Considerations
  • Use only one branch in each condition if possible; if there is an alternative option add this as a statement.
  • Always use the true branch if possible to do so.
  • Questions must remain in the correct order, exactly as they appear in the original questionnaire.
  • Multiple conditions can be derived from one question.
  • Conditions can apply to more than one question.

A Condition is a set of logic that enables questions to be asked only in certain cases. If a question is asked which is dependent on the answer to another question, a condition is needed. Conditions are usually a narrowing of who answers a question or are directional. Conditions have a 'True branch', where the condition text leading to the next question is true. They also have a 'False branch', where the response to the condition text leading to the next question is false and so does not lead to the next question. Only one branch in each condition is usually used and if possible this should be the true branch.

In Archivist a condition is made up of the label, condition text, condition logic and it has a positional element. The condition gets labelled after the question that the condition depends on. This is usually the preceding question. The label should be in the format c_q[questionref], for example c_q18. See Construct a Label for more on how to name conditions.

Most conditions have a straightforward structure which funnels certain respondents towards the next question. For example, if question 1 is 'Do you smoke?' with the answers 'Yes' or 'No', then further questions might only be required for those who answered 'Yes'. This will lead to the next question being situated in the true branch. If the answer is 'No' the respondent skips to the next question.

It is common that the condition is included in the same sentence as the question text, in which case this needs splitting to avoid repetition. In Example 1 below, 'If yes,' becomes the condition text and the 'please could you describe' becomes the question text. Note that the 'p' in 'please' is kept in lower case. There is often a natural break such as a comma to help with the decision on how to split text. But if not, then you must use your own judgement.

Info
titleExamples

More complex condition examples:

Anchor
simple
simple
Example 1 ALSPAC My Son/Daughter’s Health and Behaviour 1994

Questionnaire layout:

Archivist view (alspac_94_msdhb):

Anchor
Elsebranch
Elsebranch
Using the else branch

In Example 2, the true branch cannot be used because the questions must appear in the correct order. Question A13di must come next but this is not true to the condition ‘Go to A13e below', and so it is added to the false branch. The directional statement ‘Go to A13e below’ is incorporated into the condition text and the true branch is left empty.

Example 2 Questionnaire: ALSPAC My Son/Daughter’s Health and Behaviour 1994

Questionnaire layout:

Archivist view (alspac_94_msdhb):

Anchor
Multiple
Multiple
Multiple condition text for one question

There are occasions when there are two options for the condition from one question. In this case, the true branch is used if possible, and the alternative option is added as a statement. In Example 3 below, 'If yes' is the true branch and is entered as the condition. ‘If no, go to A4 on page 4’ is entered as a statement, positioned before the condition. If a directional statement is on its own (with or without a directional arrow) or directs you to the next question, it does not have any meaning and as such it is left out. In Example 4 below, 'Go to Section D' is ignored.

Example 3 Questionnaire: ALSPAC My Son/Daughter’s Health and Behaviour 1994

Questionnaire layout:

Archivist view (alspac_94_msdhb):

Example 4 Questionnaire: ALSPAC My Son/Daughter’s Health and Behaviour 1994

Questionnaire layout:

Archivist view (alspac_94_msdhb):

Anchor
Multiple2
Multiple2
Multiple conditions from one question

There could be cases where two (or more) conditions are dependent on the same question. They are named after the (first) question they refer to. See Construct a Label on how to name multiple conditions. In Example 5 below, there are two conditions, (If "wet.") and (If "dry."), which are both named after question 8(a). However, the conditions reference both 8(a) and 8(b). Answering question 8(c) will be conditional on answering 'wet' to question 8(a) or 8(b). Answering question 8(d) will be conditional on answering  'Never wet' to question 8(a) and 8(b).

Example 5 Questionnaire: NSHD School Nurse’s Interview with Mother 1952

Questionnaire layout:

Archivist view (nshd_52_iwm):

Anchor
Constructed
Constructed
Constructed conditions

There are some cases when there is not enough text provided in the questionnaire to create a condition and so we must construct it. A simple case of a constructed condition is where an arrow plus a 'go to' statement in the questionnaire directs the respondent to the next question. In Example 6 below, there is no ‘If yes’ condition given in the questionnaire. By adding text that is not originally in the questionnaire, a condition is constructed. The text is created by adding 'If [category] to question [question number] [condition text if included]. So the whole text of the condition becomes; ' If Working part-time to question 7a.

Example 6 Questionnaire: NSHD Postal Questionnaire 1969

Questionnaire layout:

Archivist view (nshd_69_pq):


 

In rare cases, a question can include an answer option in the code list that indicates that the question may not be applicable to some respondents. And therefore it would be skipped. A condition, although implied, is not given in the questionnaire. A separate question is constructed using the answer option which indicates the next questions will not be answered. In Example 7 below, a condition is constructed using text from this answer option 'if we are never apart'. The true branch of the condition is left empty and the main (original) question is placed in the false branch.

Example 7 Questionnaire: ALSPAC My Son/Daughter’s Health and Behaviour 1994

Questionnaire layout:

Archivist view (alspac_94_msdhb):

Anchor
If
If
Conditions that do not contain ‘If’

Sometimes it may not be obvious that a condition is necessary - the word ‘If’ may not have been used. However, it is still treated as a condition and entered in the standard way. In Example 8 below, the condition 'For those still attending' narrows the number of respondents who answer the next question.

Example 8: NSHD Questionnaire: School Questionnaire 1963

Questionnaire view:

Archivist view (nshd_63_sq):

Anchor
Logic
Logic
Condition logic

In addition to the condition's text, the logic of the condition is coded. Although it is not a DDI requirement, the condition logic is added so that it can be systematically extracted for programmatic use. To do this we use a set of standard condition logic. The process requires condition logic to reference a question construct and the response domain which the condition is based. The logic references the question(s) that gives rise to the condition, the comparison being made (==, !=, <, >) and the answer that makes the condition true (or false in some cases). See Table 1. Condition Notation for more details.

The set of condition logic is based on Boolean operators (OR, AND, NOT) used in programming or database searching. These operators, particularly OR and AND, are used to combine pieces of condition logic code. The symbols || and && are used to denote OR and AND, respectively. See Example 5 above. Condition logic is placed within square brackets adjacent to the condition text. In Example 3 above, [qc_A3_a == 1] describes that the respondent should advance to the true branch if they responded with code list value 1 to question qc_A3_a.

The answer giving rise to a condition can be a code list value, numeric answer or a text answer. Most condition logic refers to a code list value from a previous question. The corresponding code value is used without any quotations as seen in Example 3. For numeric answers single quotations are used (see Example 9) and for text answers double quotation marks are used (see example 10). Table 1. Condition Notation provides a summary.

Example 9 below [qc_20 >= ‘1’] describes that the respondent should advance to the true branch if they answered with a number greater than or equal to 1 to question qc_20.

Example 9 Questionnaire: NCDS Educational questionnaire 1969

Questionnaire layout:

Archivist view (ncds_69_eq):

Example 10 Questionnaire: NCDS Parental Questionnaire 1974

Questionnaire layout:


Archivist view (ncds_74_pq):  


Anchor
Grids
Grids
Grids and condition logic

A one column grid is the most common kind of grid structure used and is the simplest to reference in the condition logic. Grid coordinates, $X;Y, are used to specify a cell or multiple cells of a grid. See Table 2. Grid Coordinates for more details. In Example 11 below, you can reference the grid as a whole because the question states that the answer is for any of the sub-questions B2a-s.Implicit in the grid logic is that each cell answer is considered to be an ||, so in this example any of the answers could equal 3 rather than an && which would mean all answers must be 3.

Also note that, 'Otherwise go to section C.' is added on to the condition text as there is no suitable position to enter it as a statement.

Example 11 Questionnaire: ALSPAC CHILD'S BEHAVIOUR AND ABILITIES 1999

Questionnaire layout:


 

Archivist view (alspac_99_cba):

 

A more complicated condition in terms of grid logic is shown in Example 12 below. In this case, only some of the answer responses in the grid are applicable (marked with an *) for the condition to be true. Therefore, the condition logic only references these specific grid cells. See Table 2. Grid Coordinates for more details.

Example 12 Questionnaire: My Son/Daughter’s Health and Behaviour 1994 (ALSPAC)

Questionnaire layout:

Archivist view (alspac_94_msdhb):

Anchor
Empty
Empty
Conditions containing ‘empty’ logic

It is possible to have a condition which does not relate to a question. This is common in the introduction to a questionnaire. In Example 13 below, there is no previous question that the condition can be based on such as: 'Has the child died?'. In this case, there is no condition logic to be entered and the square brackets appear empty in Archivist view.

Example 13 Questionnaire: NSHD School Nurse’s Interview with Mother 1952

Questionnaire layout:

Archivist view (nshd_52_iwm):

Anchor
Ranges
Ranges
Using ranges in condition logic

There may be a large number of code values in the code list that give rise to true answers to the condition. In this case, using the operator OR (||) would make the condition logic rather lengthy. If code values are mostly sequential, we can use ranges instead to shorten the condition logic statement. In Example 14 below, instead of using OR as follows, [qc_C14 == 1 || qc_C14 == 2 || qc_C14 == 3 ... || qc_C14 == 7 || qc_1 == 8] we can use && and add a range [qc_C14 >= 1 && qc_C14 <= 8].

 Example 14: Questionnaire: BCS Friends and the Outside World 1986

 Questionnaire view:

Archivist view (bcs_86_fatow):

Anchor
Null
Null
Using NULL in condition logic

The term ‘NULL’ is used to represent missing or inapplicable information. A NULL value indicates a lack of a value, which is not the same thing as zero.  Likewise, no response is not the same as an answer of "no". If there is no answer response to a question, we use NULL in the condition logic to denote this. When this is the case for a code list does not equal (!=) is used to denote that none of those code values where chosen rather than NULL which is used for text, numeric or date response domains. In Example 15 below, if the respondent does not give a date there will be no answer value to question E15.

Example 15 Questionnaire: NCDS Self Completion 2002

Questionnaire view:

Archivist view (ncds_02_sc_2):

Advanced condition

Conditions range in complexity within questionnaires. Sometimes conditions have complex condition logic, for example, when the logic refers to axes in a question grid, as shown in Example 16 below:

Example 16 Questionnaire: ALSPAC Parent Adult Learning 2004

Questionnaire layout:

Archivist view (alspac_04_pal):

 

Anchor
Condition Notation
Condition Notation

Tip
iconfalse
titleTable 1. Condition Notation

Comparisons

==

Is equal to

!=

Is NOT equal to

Less than

Greater than

Joining

&&

To join two comparisons using an AND

||

To join two comparisons using an OR

Qualifiers

‘ (single quote)

Meta value

“ (double quote)

Literal string

 

 

Anchor
Grid Coordinates
Grid Coordinates

Tip
iconfalse
titleTable 2
borderWidth= 500.0px;

Grid coordinates

$X;Y

Used to specify a cell or multiple cells of a grid


qc_example$3;2

 

Example

Col 1

Col 2

Col 3

Row 1

 

 

 

Row 2

 

 

 

Row 3

 

 

 

 

qc_example$2;*

 

Example

Col 1

Col 2

Col 3

Row 1

 

 

 

Row 2

 

 

 

Row 3

 

 

 

 

qc_example$*;1

 

Example

Col 1

Col 2

Col 3

Row 1

 

 

 

Row 2

 

 

 

Row 3

 

 

 

 

qc_example

 

Example

Col 1

Col 2

Col 3

Row 1

 

 

 

Row 2

 

 

 

Row 3

 

 

 

 

qc_example$2:3;*

Example

Col 1

Col 2

Col 3

Row 1

 

 

 

Row 2

 

 

 

Row 3

 

 

 

 

qc_example$1,3;*

Example

Col 1

Col 2

Col 3

Row 1

 

 

 

Row 2

 

 

 

Row 3