This post was kindly contributed by StudySAS Blog - go there to comment and to read the full post. |
Last week my manager asked me to randomly pick 10%observations from a large data set and then create a listing so that the Data management programmers can QC the data. I want to share some thoughts here … how easy and simple to do random sampling.
Approach 1:
Data step Approach: In this approach, the observations are shuffled using the RANUNI function which assigns a random number to each observation.
Step1: Generating the Random Vector (shuffling) using the RANUNI function;
The RANUNI function generates a random number from a continuous uniform distribution (the interval (0, 1).
Step2: After assigning a random number to each record, the records can then be sorted in ascending or descending order of the random numbers.;
data randsamp ;input patno @@; random=RANUNI(-1);* RANUNI function to assign a random number to each record.;* Here the seed is negative integer (-1) so the results are not replicable.;cards; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23…
[[ This is a content summary only. Visit my website for full links, other content, and more! ]]
This post was kindly contributed by StudySAS Blog - go there to comment and to read the full post. |