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!
Related Posts with How to write a while statement for the purpose detailed in the post?
Naming tempfilesI wanna use the stockquote command to get some stock market data. The synatax Code: stockquote ^GSP…
Reshape with two columns to rowsHi, I am trying to reshape a dataset so that the rows in variable "title" become columns, while the …
Reverse Coding a Count VariableHi All, I hope you are doing great. I have a question about reverse coding a count variable. I have …
Question on Intraclass correlation coefficients (ICC): two-way mixed effectsHi! I wish to use ICC to look at test-retest reliability using two sets of data reported by the same…
Count by groups 5 years after the current yearDear Statalist, I am wondering if you can help me to count the number of times a given attribute is …
Subscribe to:
Post Comments (Atom)
0 Response to How to write a while statement for the purpose detailed in the post?
Post a Comment