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 (May 2001, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 7 May 2001 16:38:17 -0700
Reply-To:     kmself@IX.NETCOM.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Karsten M. Self" <kmself@IX.NETCOM.COM>
Subject:      Re: Randomly pick
In-Reply-To:  <tfe6gejs2qhldb@corp.supernews.com>; from brian-vuong@USA.NET on
              Mon, May 07, 2001 at 02:55:47PM -0700
Content-Type: multipart/signed; micalg=pgp-sha1;
protocol="application/pgp-signature";

on Mon, May 07, 2001 at 02:55:47PM -0700, Brian Vuong (brian-vuong@USA.NET) wrote: > Dear SAS users: > Please help me with random generator. After I ran codes listed below to > randomly pick 5000 records. I later found that in those 5000 records > consists of duplicates. Please show me to randomly pick 5000 records > without duplicates. > > > data select; > do i=1 to 400; > j= (ranuni(0)*total); > set auditing.recaudit point=j nobs=total; > output; > end ; > stop; > run;

How about:

data ransel; sortby = ranuni(0); set auditing.recaudit; run;

proc sort data= ransel; by sortby; run;

data select; set ransel obs=5000; run;

proc datasets lib=work; delete ransel; run; quit;

...not the fastest solution, but guaranteed to sample without duplication, using a pseudorandom key.

-- Karsten M. Self <kmself@ix.netcom.com> http://kmself.home.netcom.com/ What part of "Gestalt" don't you understand? There is no K5 cabal http://gestalt-system.sourceforge.net/ http://www.kuro5hin.org


[application/pgp-signature]


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