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?
basic question on coefplot subgraphsDear all, I have a basic question on coefplot. I would like to plot two subgraphs and apply heading…
Graph with laddersHello! I have data on employment by sector by country. When I group variables, sorting by year and …
Coefplot matrix with transform option when the matrix contains missing valuesHello everyone, I am always being helped a lot from past threads, but this time I need to start a n…
Help! Standard deviation interpret?How much would Expenditure have to increase, holding Percent constant, to increase SAT by one standa…
Stata Graph Not DisplayingWhen I run my command, the graph viewer appears but not the graph itself. It only appears after I cl…
Subscribe to:
Post Comments (Atom)
0 Response to How to write a while statement for the purpose detailed in the post?
Post a Comment