```Date: Tue, 23 Apr 1996 22:36:53 +0100 Reply-To: John Whittington Sender: "SAS(r) Discussion" From: John Whittington Subject: Re: Help Needed on Random Numbers Comments: To: Wei Yen On Tue, 23 Apr 1996, Wei Yen wrote: >A friend of mine wants to generate random numbers with no duplicates from >the series of 0-99. She wants to make ten draws, each consisting of ten >numbers. So by the tenth draw, all the numbers in the series should be >exhausted. Any suggestions? This sounds horribly like one of those homework question, but, nevertheless .....! Wei Yen, with the contraints you mention (all 100 numbers to be used, with no dupicates) what your friend will produce will not strictly be 'random numbers'. However, to divide the 100 numbers up, 'at random' into 10 blocks of 10 is easy enough - just allocate a random number to each of the values 0-99, sort by this random number, then take each consecutive block of 10 as 'a draw': data one ; do number = 0 to 99 ; rand = ranuni(123456) ; output ; end ; run; proc sort data = one ; by rand ; run ; data done (drop = rand); set one ; draw = floor((_N_ - 1) / 10) + 1 ; run ; proc print data = done ; run ; John ----------------------------------------------------------- Dr John Whittington, Voice: +44 1296 730225 Mediscience Services Fax: +44 1296 738893 Twyford Manor, Twyford, E-mail: johnw@mag-net.co.uk Buckingham MK18 4EL, UK CompuServe: 100517,3677 ----------------------------------------------------------- ```

Back to: Top of message | Previous page | Main SAS-L page