# Is this a valid way to get a simple random sample?

I have a data set of about 200,000 observations about establishments in my district and their operating time. I need to establish the correctness of my data. Consequently, I am trying to take a simple random sample of 500 observations and get their operating time physically ascertained. In order to take the sample I have followed the following steps in MS Excel:

1. Assign random values between 0 and 1 using the Rand() function to each of the 200,000 observations;
2. Sort the data in descending order on the basis of the random values assigned;
3. Select the top 500 observations.

I would like to know if this is the right way to take a simple random sample. If not, why and what should I do to make it random?

The method you are using is a commonly used method developed in Sunter (1977). It does indeed give you a valid simple-random-sample-without-replacement. The only drawback of your method is that you are using Excel for the randomisation, which does not allow you to "set the seed". This means that your randomisation is not "reproducible" (i.e., an auditor cannot recover the same sample as you by replicating your method).

If you would like to conduct a reproducible randomisation (which is much better) then you could program the same method in R as follows. (With this code, the vector SAMPLE gives you sorted index values for a random sample of n objects from the population of N objects.)

#Set population and sample sizes
N <- 200000;
n <- 500;

#Set the seed for randomisation
set.seed(75638643);

#Conduct SRSWR via uniform RVs
RAND   <- runif(N);
SAMPLE <- sort(order(RAND)[1:n]);


Or, even simpler, you could just use the sample function:

#Set population and sample sizes
N <- 200000;
n <- 500;

#Set the seed for randomisation
set.seed(75638643);

#Conduct SRSWR using sample function
SAMPLE <- sort(sample(1:N, size = n, replace = FALSE));

• Thanks Ben for this valuable info on how to achieve the same in R. I am quite new to R and just starting out. This will definitely help me a lot. Could you please elaborate a little on set.seed(). What does this do? – Asim Bhawsinghka Sep 6 '19 at 6:59
• Have a look at this related answer to see if it answers your query. – Reinstate Monica Sep 6 '19 at 8:27
• One makes such a procedure reproducible in Excel by pasting the values of RAND() to memorialize them. – whuber Sep 6 '19 at 14:36
• Kinda - I wouldn't really call that a reproducible randomisation. The auditor can then see a list of constant values, but can't reproduce them via a PRNG mechanism. – Reinstate Monica Sep 6 '19 at 23:01
• @Asim: I think that is his point - you paste them as numeric values to stop them being recalculated. – Reinstate Monica Sep 12 '19 at 7:45