Date: Mon, 20 Dec 1999 03:34:29 GMT
Reply-To: SAlbert <salbert@AOL.COMSTOPSPAM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: SAlbert <salbert@AOL.COMSTOPSPAM>
Organization: AOL http://www.aol.com
Subject: Re: random sampling
Ju-Tsung Pi wrote:>
> I have a data set of 887 observations from a normal distribution. I
>would like to draw a
> sample of 250 observations out ot 887 obs. How can I do this?
> Thanks!
>
If you only need approximately 250, you can use code like the following:
data two;
set one(where=(ranuni(0) < 250.0/887));
run;
If you need an exact 250, you could try several approaches, but the easiest
would be to add a random variable, sort on it, and then take the first 250
cases:
data two;
set one;
dummy = ranuni(0);
run;
proc sort data=two;
by dummy;
run;
data three;
set two(obs=250);
run;
Note: code above has not been tested.
Steve Albert
|