LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 13 Mar 2000 13:04:27 -0500
Reply-To:     Jim Linck <linck@SSB.ROCHESTER.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Linck <linck@SSB.ROCHESTER.EDU>
Organization: University of Rochester
Subject:      Efficient way to randomly grab one record from a group of records

Here's something I've been struggling with in terms of finding an efficient way to do this (my methods are always too slow and time-consuming). Suppose I have the following list:

1 2 1 3 1 1 1 4 1 6 2 3 2 4 2 1 2 3 2 6

where I will refer to the first column as ID and the second as ID2. What I want is the simplest way to 'randomly' grab one record for each ID. Efficiency is important as I'll be doing this on a large dataset and will repeat it a 1000 times. My old method was to generate a random number for each record, sort by that random number, then pick the first record in another data step. This, however, turns out to be too time consuming.

Any ideas?

Thanks, Jim

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