Professional Documents
Culture Documents
Case Selection: Variable Expressions
Case Selection: Variable Expressions
Variable Expressions
You can specify a single variable or an expression involving several
variables.
To insert a variable name, select the variable in the list box at the right
and then double-click.
Relational Operators
The following relational operators are available:
= equals
!= not equal
< less than
> greater than
<= less than or equal
>= greater than or equal
& and
| or
, or (comma, used in a series)
! not
Examples
Examples of selection conditions given by "where" expressions are:
(The first statement will select any accounts that have 2's as the 5th and
6th characters in the string, while the second statement will select
strings of any length that begin with 3.)
The comma operator ',' is used to list different values of the same
variable name that will be used as selection criteria. It allows you to
bypass lengthy "or" expressions when giving lists of conditional
values.
Missing Values
You can test to see that any variable is missing by comparing it to the
special, internal variable, '_missing'. For example
Selecting Cases
You can select specific rows by using the special, internal
variable ‘_rownum’. For example, you can select the first 50
cases by using the following expression:
where _rownum % 5 = 0
Sampling Functions
Three functions are available for sampling.
The first
samp_rand(prop)
The second
samp_fixed(sample_size,total_observations)
selects a random sample of fixed size. The first case is drawn with a
probability of 'sample_size/total_observations', and the succeeding i'th
case is drawn with a probability of '(sample_size - hits) /
(total_observations - i)'
samp_syst(n)
performs a systematic sample of every n'th case after a random start.
Expressions are evaluated from left to right. You can thus sample from
a subset of your cases by subsetting them first and then sampling. For
instance to take a random half of high school graduates use: