I would like to, when certain criteria are met, change where I'm at in a loop. Here is a MWE. In this code, I would like to cycle normally through v = 1, then 2, 3, 4, 5, but then skip to 56, 57, 58, 59. (I'm envisioning that the value of v is 5, then I add 50 to it, thus 55. Then when it goes back to the top of the loop it would increment to 56. Hence no 55 in the desired output below.) I thought that simply referring to the same local macro name would do it, but obviously I'm wrong.
Desired output:
I just want to check on this value:1
I just want to check on this value:2
I just want to check on this value:3
I just want to check on this value:4
I just want to check on this value:5
I just want to check on this value:56
I just want to check on this value:57
I just want to check on this value:58
I just want to check on this value:59
Code:
forvalues v = 1/59 { display "I just want to check on this value:`v'" if `v' == 5 local v = `v' + 50 }
I just want to check on this value:1
I just want to check on this value:2
I just want to check on this value:3
I just want to check on this value:4
I just want to check on this value:5
I just want to check on this value:56
I just want to check on this value:57
I just want to check on this value:58
I just want to check on this value:59
Comment