/* Richard A. DeVenezia * www.devenezia.com */ /* This problem was sent in private correspondence * June 12, 2003. */ /* Dear Friend: I got bit by this recently. A. What is the most number of rows table fakedata could have ? B. What is the least number of rows table fakedata could have ? */ data fakedata; x = 0; do while (x<100); y = ranuni(0); output; * increment by one or two; x + 1 + ranuni(0)<0.25; end; run; /* Some answers might be A. 100 - if all the randoms are < .25 99 - if all the randoms are < .25, and I can't count from zero B. 50 - if all the randoms are >=.25 49 - if all the randoms are >=.25, and I can't count from zero In reality, the program is an endless loop! x + 1 + ranuni(0) < 0.25 evalutes to x +(1 + ranuni(0))< 0.25 (1 + ranuni(0)) is alway > 0.25, thus x +(1 + ranuni(0))<0.25 is really x + 0 The correct incrementing statement would be x + 1 + (ranuni(0)<0.25); */