You can just check if no 1-sequence starts in r1 or ends in r10. If that's the case you just take first column or last column to be the start/end. -Michael set i /r1*r10/, j /c1*c6/, iter /1*3/; parameter rowstart, cnt, randval(i,j) Random values, randvalloop(iter, i,j) Store the random values; $set...