Dear all,

I have two variables: seq1 and u.

seq1 is a repeating sequence: 1,2,3,4,5
u is a random integer between 1 and 5, generated by u = 4*uniform() + 1

Now I want to achieve this: when u equals to seq1, do the randomisation again until u has a different value as seq1.

My code is:

foreach var in u{
foreach num in seq1{
while `num' == `var'{
replace `var' = 4*uniform() + 1)
}
}
}

No error in this code but it didn't work for my purpose. After I run it, nothing changed.

So would you mind help me figure out why this code cannot work and what I need to do to achieve my purpose?

Thank you very much!