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?
Drop if in rangeHello, how can I drop a group if there is a missing value in any variable per group. In the example…
Interaction analysis - Problematic Wald test results- …
Dropping unnecessary variable from BRFSS data to save spaceIs there any efficient way to keep the variables I need and drop all the unnecessary variables ? In …
fe and first-difference estimator with controls and weight in baseline yearI have been learning from Statalist for some years now. Thank you for being there for us! First time…
How to force vertical lines to be above of all horizontal lines using twowayDear all, How do I force the gray area to be above the yellow areas in the graph below? Code: cle…
Subscribe to:
Post Comments (Atom)
0 Response to How to write a while statement for the purpose detailed in the post?
Post a Comment