Ophelia,

This is very easy in R. Just use sample() to sample the indices of the rows,
for example:

data.out<-NULL
for (i in 1:10000){
data.out<-rbind(data.out, mean(data.all[sample(1:nrow(data.all), 470,
replace=F),]))
}

This creates a data frame, "data.out" with the 10,000 means of your samples.
I assume you want sampling without replacement. If you want with
replacement, just change the false to a true in the call to sample. 

George


..................................................................
George W. Gilchrist                           Email: [EMAIL PROTECTED]
Director of Graduate Studies                 Phone: (757) 221-7751
Department of Biology, Box 8795                Fax: (757) 221-6483          
College of William & Mary  
Williamsburg, VA 23187-8795
http://gwgilc.people.wm.edu/



On Thu, 12 Apr 2007 09:34:30 +0200, John P Ball <[EMAIL PROTECTED]> wrote:

>Dear Ophelia
>
>Random sampling is extremely easy to do in SAS.  Just visit
>
> http://support.sas.com/techsup/sample/random.html
>
>Just copy the fully commented code and paste it into your program.
>
>There, you will find the code to do:
>
>1) simple random sampling (with or without replacement)
>
>and
>
>2) many varieties of stratified random sampling (e.g. with and without
>replacement, equal allocation, unequal allocation...)
>
>You will also find SAS code to directly perform bootstrapping,
>crossvalidation, and jackknifing for every statistic that you could
>calculate in SAS (which is darn near everything in the statistical
>realm...).
>
>For lots of SAS code to do a huge variety of things, visit www.sas.com
>then select Tech support, then just type in a few search words for what
>you are trying to do (e.g. " Akaike's Information Criterion" or
>"Schwarz's Bayesian Criterion" ).  You will be hard pressed to NOT find
>the code to do what you need to do!
>
>It is hard to match SAS for the sort of thing you ask about...
>
>John P. Ball
>
>> Date:    Wed, 11 Apr 2007 00:49:37 -0500
>> From:    Ophelia Wang <[EMAIL PROTECTED]>
>> Subject: Question about random sampling
>>
>> Hi,
>>    I have a data set that has about 15,000 data points (rows) that
>document
>> values of 15 variables (columns). Now I'd like to perform a random
>sampling
>> process (run 10,000 times) to randomly select 470 points and get the
>mean
>> values of my 15 variables (columns) out of these 470 points after the
>10,000
>> times of random sampling. Can anyone tell me how to write a script in
>SAS,
>> SYSTAT, R or S-Plus to perform this analysis? Or are there other
>methods I can
>> use? Thanks a lot! Ophelia
>> --
>> Ophelia Wang
>> Doctoral student
>###########################################
>
>This message has been scanned by F-Secure Anti-Virus for Microsoft Exchange.
>For more information, connect to http://www.f-secure.com/
>=========================================================================

Reply via email to