Conditions

Key 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.

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.

Labelling

The label should be in the format c_qquestionref, for example c_q18. The condition label contains a collapsed version of the question label it references. That is, any underscores which are in the question label are removed from the condition label in order to distinguish between the question number and the condition number. For example if a condition was labelled c_q14_ii it would not be able to tell if this refers to question 14_ii or whether it is the second condition from question 14. If it was referring to question 14_ii then the condition label would be c_q14ii. See Construct a Label for more on how to name conditions.

 

The following list details the examples which are included within this wiki page.

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

Questionnaire layout:

Archivist view (alspac_94_msdhab):

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

Questionnaire layout:

Archivist view (alspac_94_msdhab):

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

Questionnaire layout:

Archivist view (alspac_94_msdhab):

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

Questionnaire layout:

Archivist view (alspac_94_msdhab):

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):

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 the words 'go to' in the questionnaire direct the respondent to the next question.

Please see Example 6 below for the constructed condition literal with “Go to”. In this example, the condition literal is created by adding 'If category to question question number condition text if included’. The condition text becomes ‘If don’t have a job to question G3d Go to G9 Page 29’.

Example 6 Questionnaire:  ALSPAC - A Toddler in the House – Partners Questionnaire

Questionnaire layout:

Archivist view (alspac_93_atith):

Example 7 below is similar to Example 6 where the condition is represented by an arrow. In Example 6, the conditional text after the condition is “Go to G9 Page 29” and is included in the condition, whereas in Example 7 it is ‘29’. If we were to follow the constructed text formula 'If category to question question number condition text if included’, the condition text would be 'If Get a full-time job to question 27 29’. This does not make sense, therefore we do not include ’29’ in the condition text, and the condition text becomes 'If Get a full-time job] to question 27’. This is preferable to adding additional text which is not included in the questionnaire. 

Example 7 Questionnaire: US - COVID-19 Wave 6 Youth Self-completion Questionnaire

Questionnaire layout:

Archivist view (us_covid_yq6):

In Example 8 below, the condition is represented by “…..” instead of an arrow as it is in Example 2. By adding text that is not originally in the questionnaire, a condition is constructed to represent the “…”. So, the condition text becomes; 'If Working part-time to question 7a’, following the same principles of 'If category to question question number condition text if included’.

Example 8 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 9 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 9 Questionnaire: ALSPAC My Son/Daughter’s Health and Behaviour

Questionnaire layout:

Archivist view (alspac_94_msdhab):

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 10 below, the condition 'For those still attending' narrows the number of respondents who answer the next question.

Example 10: NSHD Questionnaire: School Questionnaire 1963

Questionnaire view:

Archivist view (nshd_63_sq):

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 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. Brackets should only be used within condition logic when you have &&'s and ||'s (see Example 11 below).

Example 11 Questionnaire: US - Wave 1 Questionnaire

Questionnaire layout:

Archivist view (us1):

 

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 12 below) and for text or date answers double quotation marks are used (see example 13). Table 1. Condition Notation provides a summary.

Example 12 below describes that the respondent should advance to the true branch if they care for more than 1 person in their household.

Example 12 Questionnaire: US - COVID-19 Wave 7 Questionnaire

Questionnaire layout:

 

Archivist view (us_covid_q7):

 

Example 13 Questionnaire: US - Wave 3 Questionnaire

Questionnaire layout:

 

Archivist view (us3):



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 14 below, there is no previous question that the condition can be based on such as: 'Are you in full-time work?'. Therefore there is no condition logic to be entered and the square brackets will appear empty in the Archivist doc view.

As there is no question to reference, the condition label is labelled after the first question that is dependent on that condition in this case qc_51e. See Construct a Label for more on how to name conditions.

Example 14 Questionnaire: NSHD Main Questionnaire 1989

Questionnaire layout:

Archivist view (nshd_89_mq):

Sometimes condition logic provided by the study contains a question that exists in the questionnaire, but the question is related to feedforward information. We do not include feedforward information in our condition logic, so in this case, the condition logic should be empty in Archivist, and the condition should be labelled after the first question inside the condition. 

In the example below, the condition logic would be left blank, as question NWRK is referenced in relation to the feedforward variable FFNWRK00. The condition would be labelled after CONU, which is the first question inside the condition.

Example 15: MCS Age 14 Parent Questionnaire (mcs_15_pq)

Using ranges to shorten the 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 16 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 16: Questionnaire: BCS Friends and the Outside World 1986

 Questionnaire view:

Archivist view (bcs_86_fatow):

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 was chosen rather than NULL which is used for text, numeric or date response domains. In Example 17 below, if the respondent does not give a date there will be no answer value to question E15.

Example 17 Questionnaire: NCDS Self Completion 2002

Questionnaire view:

Archivist view (ncds_02_sc_2):

Using dates in condition logic


When dates are written using only numbers they can be represented in a number of ways. Not having a standard format for dates could create issues when interpreting the data in a later stage. We have adopted the internationally agreed ISO 8601 standard for inputting dates as numbers. This has the format of YYYY-MM-DD

Example 18 Questionnaire: National Survey of Health and Development (nshd_72_mq)

Questionnaire view:

 Archivist view (nshd_72_mq):

If the comparison involves an answer to a question in date format, we can compare the answers directly. Please see Example 19 below:

Example 19 Questionnaire: (alspac_covid_q5)

Archivist view (alspac_covid_q5)


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 20 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 OR, so in this example any of the answers could equal 3 rather than an AND which would mean all answers must be 3. Please refer to Example 22 as to how to reference grid cells using the AND comparator. 

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 20 Questionnaire: ALSPAC Child’s Behaviour and Abilities

Questionnaire layout:



Archivist view (alspac_99_cba):



A more complicated condition in terms of grid logic is shown in Example 21 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 21 Questionnaire: ALSPAC My Son/Daughter’s Health and Behaviour

Questionnaire layout:

Archivist view (alspac_94_msdhab):



Grid cell referencing

Conditions range in complexity within questionnaires and sometimes need to reference specific cells within a grid. When referencing several cells in a grid at once, each of the grid cells in the logic is effectively compared with an OR e.g. if the logic qc_A3 != 1 was used for the example below, to cover all grid cells, it would effectively be qc_A3$1;1 != 1 || qc_A3$1;2 != 1 || qc_A3$1;3 != 1. This would mean that any of the options could not equal 1, but we need all of the options not to equal 1. Therefore, each cell has to be referenced individually qc_A3$1;1 != 1 && qc_A3$1;2 != 1 && qc_A3$1;3 != 1 with AND in between.

Example 22 Questionnaire: ALSPAC Parent Adult Learning

Questionnaire layout:

Archivist view (alspac_04_pal):



Table 1. Condition Notation

==

Is equal to

!=

Is NOT equal to

Less than

Greater than

&&

To join two comparisons using an AND

||

To join two comparisons using an OR

‘ (single quote)

Meta value (numeric)

“ (double quote)

Literal string (text, date)

$Col;Row

Used to specify a cell or multiple cells of a grid

Example

Col 1

Row 1



Row 2



Row 3



Example

Col 1

Row 1



Row 2



Row 3



Example

Col 1

Col 2

Col 3

Row 1







Row 2







Row 3







Example

Col 1

Col 2

Col 3

Row 1







Row 2







Row 3







Example

Col 1

Col 2

Col 3

Row 1







Row 2







Row 3







Example

Col 1

Col 2

Col 3

Row 1







Row 2







Row 3







Example

Col 1

Col 2

Col 3

Row 1







Row 2







Row 3