UCL Logo
Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 41 Next »

Key Considerations

  • Loops are used for repetitive questions.
  • Loops are also used when grids have no over-arching question texts.

The term ‘loop’ is used to describe a series of actions that are completed over and over until a certain condition becomes true.

“Place once slice of bread buttered side up, then add lettuce, two slices of cheese, and top with another slice of buttered bread, face down. Repeat this until you have four sandwiches.”

In DDI 3.2, a Loop is useful when describing a series of repeating questions. They can include all types of constructs, including question grids, conditions, sequences and even other loops. The limit to how many times the question is repeated per instance is set by a logic (a mathematical representation of a decision point, where different choices route the participant different ways). This logic either draws on a source outside of the loop, such as a previous question, or it is stated directly within the loop itself. This is explained in further detail with the two examples below.

A loop can be an efficient way of condensing a repeating question set in a way that makes the material easier to read whilst not losing the original function.

When naming loops, you use the first construct that exists in the series of constructs (usually a question) that the loop describes. See Example 1 - Archivist Build and the Construct a Label page for an overall guide on labelling.

Example 1 Questionnaire: Study Mother's Questionnaire 1996 (ALSPAC)

When a loop relies on the answer to a previous question, such as how many times something has occurred, the logic used to generate the loop references the question.

Questionnaire layout:


Archivist Build / Constructs (alspac_96_smq):


Archivist view (alspac_96_smq):


In the above example, the loop l_qA10c references question qc_A10_b in the first part of the logic to begin the loop cycle. This runs as many times as the number that the questionnaire respondent originally states for ‘How many times?’:

    _pregnancy from 1 while (_pregnancy <= qc_A10_b) && (_pregnancy < 7)

In the second part of the logic, the < 7 tells us that the cycle must not run more than 6 times, as there are only six spaces to record a pregnancy shown in the original document.

  _pregnancy from 1 while (_pregnancy <= qc_A10_b) && (_pregnancy < 7)


Example 2 Questionnaire: You and Your Friends 2008 (ALSPAC)

This version of a loop does not rely on the value given in any previous question, but states that the questions are to be filled in up to five times:

Questionnaire layout:

Archivist view (alspac_08_yayf):

The loop l_friends describes the original questionnaire's requirement to fill in details about 5 friends or less. Therefore the loop runs while the value '_friend' is less than 6. We can see this represented in the loop logic:

     _friend from 1 while _friend < 6


Example 3 Questionnaire: SWS Obstetric Form (SWS)

Sometimes a loop is used where we cannot use a Question Grid, because the group of questions has no overarching text - an essential part of a question grid.

Questionnaire layout:

Archivist view (sws_3_clinic):


  • No labels