Download presentation
Presentation is loading. Please wait.
Published byShanna Beasley Modified over 9 years ago
1
Generating Random Samples SAS, EXCEL, JMP, SPSS
2
Population of Data Sample Data should be in a dataset where each row represents an individual unit, and column fields represent variables measured on the individual A new column field will be created that contains a pseudo-random number generated by statistal software package (usually Uniform(0,1) r.v.) Data are sorted by the random number, or simply selected for analysis (depending on software)
3
All ATL/HNL 10/2004 Delta Flights (N=31)
4
SAS Code to Generate Random Sample (n=10) Data Pop; Input Day FlightNum TailNum $ DestCity $ TaxiTime Sched Actual Distance; Ranx=Ranuni(seed); /* Put in a number where “seed” is */ Cards; 1317N834MHHNL295805674496 … 31317N840MHHNL165805764496 ; Proc Sort; By Ranx; Data Sample; Set Pop; If _N_ <= 10; Run; /* You can run any procedures now on the Sample */
5
Generating Random Samples in EXCEL In a new column past the data, type in the first row containing data on a unit: =RAND() COPY and PASTE that cell until all N units have a random number While that range of N cells is still highlighted, click on COPY EDIT PASTE SPECIAL Click on VALUES (This changes them from Dynamic to Static) Place Cursor in Data Field, Click on: DATA SORT Choose Column with Random Values and Choose appropriate Header Row Status After data are sorted, COPY and PASTE (SPECIAL VALUES) the first n units to a new worksheet
6
Random Numbers (Not Sorted Yet)
7
Data Sorted By Random Number
8
EXCEL Random Sample (n=10)
9
Random Samples in JMP Import Data into JMP Click on TABLES SUBSET RANDOM SAMPLE Enter Your Sample Size (e.g. 10) in Box Subset Dataset Appears in New Table Analyze the Data in that Table
10
Random Samples in SPSS Import Data into SPSS Older Versions: Click Transform Random # Seed Enter a numeric seed Newer Versions: Click Transform Random # Generators Active Generator Initialization Fixed Value Enter a numeric seed –Click Data Select Cases –Under Select, choose Random Sample of Cases. Click on Sample box. –Choose Exactly n (10) of the first N (31), click Continue –Click OK. Slashes will appear in the case numbers of the cases not in the sample, and an indicator variable representing Filter will be attached to end of dataset. –Analyze the Data
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.