Size: 1115
Comment:
|
Size: 1139
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 43: | Line 43: |
Below is a demonstration for how a sample of 200 can be randomly drawn. | Below is a demonstration for how an [[SurveySamples#Sampling_Methods|SRS sample]] can be drawn. |
SPSS Numeric Functions
Apart from arithmetic operators, SPSS also offers a library of built-in numeric functions.
Contents
Range
the RANGE function takes a variable and 1 or more pairs of low-high value pairs. It returns 1 for all cases with a value within the inclusive range of low to high.
data list free / ID (F2) Score (F2). begin data 1, 10, 2, 20, 3, 30, 4, 40, 5, 50, 6, 60, 7, 70, 8, 80, 9, 90 end data. compute InRange=range(Score,30,40,70,80). list all.
ID |
Score |
|
1 |
10 |
0 |
2 |
20 |
0 |
3 |
30 |
1 |
4 |
40 |
1 |
5 |
50 |
0 |
6 |
60 |
0 |
7 |
70 |
1 |
8 |
80 |
1 |
9 |
90 |
0 |
Uniform
The UNIFORM function selects from a random uniform distribution from 0 to N. Note that a random seed must be set first.
Below is a demonstration for how an SRS sample can be drawn.
set seed=random. compute rand=uniform(100000). rank variables=rand /rank into rrand. compute sample=0. if (rrand le 200) sample=1.