DO K = list of numbers (a block of Minitab commands and macro statements) ENDDO |
Allows you to loop through a block of commands. K is set equal to the first number in the list, then the block of commands is executed. When Minitab reaches the ENDDO, K is set equal to the next number in the list and the block is executed again. This continues until all numbers in the list are used, or until you branch out of the DO-loop with a BREAK, GOTO, RETURN, or EXIT command.
The list of numbers can be an explicit list of any numbers or stored constants. A patterned list can be abbreviated using a colon and slash as in SET. For example, 1:10 is the list 1, 2, 3, ... , 10, and 1:1.8 /.2 is the list 1, 1.2, 1.4, 1.6, 1.8. Numbers can be increasing or decreasing order. The following DO-loop changes the values in rows 1 through 10 and row 50 of columns C1 and C2 to the missing value code:
DO K1 = 1:10 50
LET C1(K1) = '*'
LET C2(K1) = '*'
ENDDO
Here is a local macro that calculates a moving average of length three. It shows how to loop through the values in a column.
MACRO |
Note |
Instead of modifying a worksheet variable inside a DO / ENDDO loop, it may be faster to copy the worksheet variable to a local macro variable, modify the macro variable in the loop, then copy the macro variable back to the worksheet variable. |