Date: Tue, 16 Nov 2004 16:37:41 -0500
Reply-To: Bob_Abelson@HGSI.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Bob Abelson <Bob_Abelson@HGSI.COM>
Subject: Re: Random selection
Content-Type: text/plain; charset="iso-8859-1"
The easiest way, although far from the most efficient, would be to assign
a random number to each observation, sort by that number, and take the
first 150 of them.
data sample;
set yourdata;
retain seed 6345789;
randno = uniform(seed);
run;
proc sort data=sample;
by randno;
run;
data sample;
set sample;
if _n_ <= 150;
drop randno;
run;
I only recommend this with relatively small datasets, like yours. Larger
datasets need a more efficient technique.
Hope this helps.
Bob Abelson
HGSI
240 314 4400 x1374
bob_abelson@hgsi.com
"Coffee falls into the stomach ... ideas begin to move, things remembered
arrive at full gallop ... the shafts of wit start up like sharp-shooters,
similies arise, the paper is covered with ink ..."
-- Honore de Balzac
Myra <myrabarnes@YAHOO.COM>
Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
11/16/2004 04:16 PM
Please respond to Myra
To: SAS-L@LISTSERV.UGA.EDU
cc:
Subject: Random selection
I have a dataset of about 2800 observations & I need to randomly select
150 of them & output them into a new dataset. How would I go about doing
this?
Thanks for any help.
~Myra~
---------------------------------
Do you Yahoo!?
The all-new My Yahoo! ? Get yours free!