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 (January 2000, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 28 Jan 2000 06:47:33 -0800
Reply-To:     "Pope, Louann" <LPope@CORNERSTONE.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Pope, Louann" <LPope@CORNERSTONE.COM>
Subject:      Re: drawing random samples
Content-Type: text/plain; charset="windows-1252"

One of my colleagues just gave me the following code earlier this week. Hope it helps.

/* This program creates a fixed size random sample with replacement (i.e. duplicate observations are allowed) from a SAS data set. Just replace mydata with your current dataset. */ data sample (drop=sampsize n); sampsize=10; do n=1 to sampsize; readit=ceil(ranuni(0)*totobs); set mydata point=readit nobs=totobs; output; end; stop; run; proc print data=sample;

/* This program creates a fixed size random sample without replacement (i.e. duplicate observations are not allowed) from a SAS data set. Just replace mydata with your current dataset. */ data sample (drop=sampsize obsleft); sampsize=10; obsleft=totobs; do while (sampsize >0); readit+1; if ranuni(0)<sampsize/obsleft then do; set mydata point=readit nobs=totobs; output; sampsize=sampsize-1; end; obsleft=obsleft-1; end; stop; run; proc print data=sample;

> In article <HR%j4.461$fF.5385@vixen.cso.uiuc.edu>, > "Del Harnisch" <harnisch@uiuc.edu> wrote: > > Can you please remind me how to draw a random sample of size n from a > > population of N observations? > > > > Thanks, > > Del > > > > Hi Del > > I have an excellent article on how to draw random samples with SAS. > Send me your fax number and I can send it to you on Monday. > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. > >


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