SUBSET procedure

Forms vectors containing subsets of the values in other vectors (R.W. Payne).


Options

CONDITION = expression
Logical expression to define which units are to be included; no default - this option must be set

SETLEVELS = string
Whether to reform the levels (and labels) of factors to exclude those that do not occur in the subset (yes, no); default no


Parameters

OLDVECTOR = vectors
Vector from which the subset is to be formed

NEWVECTOR = vectors
Vector to store the subsets if none is specified, the OLDVECTOR is redefined to store the subset


Description

SUBSET forms vectors containing subsets of the values in other vectors. The subset is defined by a logical condition which must be specified by the CONDITION option; units with true values (non-zero and non-missing) for the condition are included in the subset, others are omitted.

   Subsets can be formed for factors, texts and variates. Relevant attributes will also be transferred across to the new structures but, if the subset excludes some of the levels of a factor, a new reduced set of levels (and labels) can be requested by setting option SETLEVELS=yes.

   The original vectors are specified by the OLDVECTOR parameter and identifiers for the vectors to contain the subsets are specified by the NEWVECTORS parameter. If NEWVECTORS is not set, the OLDVECTORS are redefined to store the subsets instead of their original values.


Options: CONDITION, SETLEVELS. Parameters: OLDVECTORS, NEWVECTORS.


Method

RESTRICT is used to obtain a list of units included according to the CONDITION. This is then used to calculate a format for EQUATE to use to transfer the values. The DUPLICATE directive is used to transfer any relevant attributes. We thank Jac Thissen for suggestions about the redefinition of factor levels.


Action with RESTRICT

Any restriction is ignored; the subset is formed only from the CONDITION option.

OLDVECTOR is redefined to store the subset