Data editing > Flow control > Loops > Routing with loops
 
Routing with loops
You can route from inside a loop to outside, but not from outside to inside. The following is permissible:
do 150 t1 = 125,145,5
if (numb(c(t1)).eq.1) c189'1'; go to 76; else; c(t1)' '
150 continue
76 continue
This loop says that if a given column specified by t1 is single-coded (that is, contains one code only), set a spare column equal to 1 and send the record out of the loop. If not, set the column being checked to blank and return to the top of the loop to get the next value of t1. This process continues until a single-coded column is found, or until all values of t1 have been tried.
This loop is not permissible:
if (c176'3') go to 76
        .
        .
do 150 t1 = 125,145,5
76 if (numb(c(t1)).eq.1) c(t1+1)'&'
150 continue
If c176’3’, the program would jump into the middle of the loop and have an unidentified value for t1. An error message will be printed under the offending statement.
See also
Loops