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 2000, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 7 May 2000 00:07:29 GMT
Reply-To:     sashole@mediaone.net
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Dorfman <paul_dorfman@HOTMAIL.COM>
Subject:      Re: Sampling with replacement
Comments: To: aina@SFU.CA
Content-Type: text/plain; format=flowed

Victor,

If you _really_ need sampling with replacement, that is if you need an element of the population selected once to be re-used when pulling subsequent samples, and you already know how to pull a sample once, then just pull as many samples as you need from the same dataset without worrying about anything else.

Else if you need sampling without replacement, i.e. an element selected once must not be ever re-used again, then you need some technique of memorizing such elements and skipping them from the remainder of the population. If this is _really_ the case, and you have to pull many samples serially, the 'sort by random' method appears to be the simplest (even though I do not especially like it, since for one thing, it requires sorting). Say you have got to select 3 samples with 53, 109, and 173 records from file A. Assuming that A has enough records,

%let s1 = 53; %let s2 = 109; %let s3 = 173; data r/view=r; set a; r = ranuni(1); run; proc sort data=r out=chaos(drop=r); by r; run; data s1 s2 s3; set r (obs=%eval(&s1+&s2+&s3)); if _n_ <= &s1 then output s1; else if _n_ <= &s2 then output s2; else output s3; end;

Kind regards, ===================== Paul M. Dorfman Jacksonville, FL =====================

>From: Victor Aina <aina@SFU.CA> >Reply-To: Victor Aina <aina@SFU.CA> >To: SAS-L@LISTSERV.UGA.EDU >Subject: Sampling with replacement >Date: Sat, 6 May 2000 17:55:50 GMT > >Hello all, > >I'd like to pull out random samples from >a dataset. This is straightforward using >ranuni function in a SAS datastep. >However, I want to perform sampling with >replacement. I'd like pointers to available >SAS codes that can accomplish the task. > >Thanks, >V. >-- > > >+----------------------------------------------------------+ >| victor aina | e-mail: aina@sfu.ca | fax:(972) 255-6955 |

________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


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