Nesting Loop Objects

Nesting loop objects involves placing of a Loop Object within another Loop Object.  There is no limit to the level of nesting.

A best practice in nesting loops is to keep the same iteration type throughout the loops, and if there is a Summary Table in the Original Loop, to use Summary Tables in all nested loops.

Example of an Iterate Until Done Loop nested in another Iterate Until Done Loop:


  • The variable RESIDENCECOUNT asks for the number of people in the residence
  • The RESIDENCEMEMBERS loop uses the number of people in the residence as the minimum and maximum for the number of loops


  • Within the Loop RESIDENCEMEMBERS there is a nested loop called PRESCRIPTIONS.


  • The PRESCRIPTION loop collects the name of each prescription drug based on the number of drugs provided in a question called RESMEM_DRUGS
  • There is Show-If logic on the PRESCRIPTION loop to only show if the RESMEM_DRUGS is greater than 0.


  • The PRESCRIPTION loop uses the RESMEM_DRUGS variable to set the minimum and maximum for the number of nested loops.



  • Each loop uses a Summary Table to display the information collected.