Loops

 

Top  Previous  Next

Looping lets you specify a list and a group of questions to be asked for each member of that list.

 

Examples of its use might be:

 

to ask identical questions for each member of a family or each employee in a company

to ask identical questions about the "first time, second time, and so on" of a purchase, illness, vacation, or any other repeated occurrence

to obtain ratings for a list of attributes for a set of brands (loop within a loop).

 

For looping sequences, you'll typically want to show respondents the list element associated with that loop.  You show the text of the list element for the current loop by using the Sawtooth Script instruction [% LOOPLABEL( ) %].  For loops within loops, you'll need to specify a loop name within the argument (see details further below) to distinguish which list element you are referring to.

 

Loops require 2 anchor questions, a list to enumerate (either pre-defined or constructed) and a name. Loop names must meet the same criteria as question names: 24 characters max, no symbol characters, and must start with a letter. If the constructed list is empty, the loop sequence is skipped.

 

Looping across a question leads to dot notation question names in the data record.  For example, if Q1 is looped over 4 times (for each of 4 elements in a list), the data are stored as Q1.1, Q1.2, Q1.3, and Q1.4.  Using a loop within a loop leads to double dot notation: Q1.1.1, etc., where the outer loop(s) are represented by the earlier dot(s) in the sequence.  Triple dot notation, etc. is possible for a loop within a loop within a loop.

 

You can invoke skip patterns within loops, where the target of the skip is the "Next Loop Iteration" or the "End of Loop".  If you are within a question called Q1, you can refer (in skip patterns) to Q1 and it will take the value from the current loop for Q1 (you do not have to refer to a specific "dot notation" to mean the current loop iteration).

 

Restrictions:

 

It isn't possible to show all looped questions (for all loops) on the same page.  (If you have a loop associated with a four item list for Q1, you always get four pages; you cannot display all four Q1's on a single page).

 

Start, Terminate, and Quota questions are not allowed in loops. Conjoint and MaxDiff exercises are not allowed in loops.

 

Script Functions within Loops:

 

Various Sawtooth Script functions are available within loops:

 

LOOPLABEL(), LOOPLABEL(Loop Name) Returns the label for the list item for the current loop. This function only works in questions established as part of a loop. The Loop Name is an optional argument that specifies, in the case that more than one loop applies (e.g. nested loops), which loop label to return.

 

 

 

LOOPVALUE(), LOOPVALUE(Loop Name)  Returns the parent list item number for the current item in the loop. This function only works in questions established as part of a loop. The Loop Name is an optional argument that specifies, in the case that more than one loop applies (e.g. nested loops), which loop value to return.

 

 

LOOPITERATION(), LOOPITERATION(Loop Name) Returns the current iteration count of the current loop. This corresponds to the position number of the current item in the looped list. For example the first time through the loop this function returns 1, the 2nd time it returns 2 and so on. This function only works in questions established as part of a loop. The Loop Name is an optional argument that specifies, in the case that more than one loop applies (e.g. nested loops), which loop iteration value to return.

 

 

AIELoopList(Loop Name, Question Name, Value) Similar to the AIE list function, except that it adds (to a constructed list) the list item from the loop list that matches instead of the list item from the question.

 

 

AIGLoopList(Loop Name, Question Name, Value) Like the AIG list function, except that it adds (to a constructed list) the list item from the loop list that matches instead of the list item from the question.

 

 

AILLoopList(Loop Name, Question Name, Value) Like the AIL list function, except that it adds (to a constructed list) the list item from the loop list that matches instead of the list item from the question.

 

 

ANELoopList(Loop Name, Question Name, Value) Like the ANE list function, except that it adds (to a constructed list) the list item from the loop list that matches instead of the list item from the question.

 

Page link: http://www.sawtoothsoftware.com/help/lighthouse-studio/manual/index.html?hid_web_skips_2.html