Forms vectors containing subsets of the values in other vectors (R.W. Payne).
||Logical expression to define which units are to be included; no default – this option must be set|
||Whether to reform the levels (and labels) of factors to exclude those that do not occur in the subset (
||Indicator set to 1 or 0 according to whether or not the subset contains no units|
||Vector from which the subset is to be formed|
||Vector to store the subsets if none is specified, the
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
NULL option can specify a scalar that will be set to one if the subset contains no units; otherwise it is set to zero. Also, when
SUBSET suppresses the fault that it normally gives if the subset is empty.
The original vectors are specified by the
OLDVECTOR parameter and identifiers for the vectors to contain the subsets are specified by the
NEWVECTOR parameter. If
NEWVECTOR is not set, the
OLDVECTOR are redefined to store the subsets instead of their original values.
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.
Any restriction is ignored; the subset is formed only from the
OLDVECTOR is redefined to store the subset.
Commands for: Calculations and manipulation.
CAPTION 'SUBSET example',\ 'Form a subset of a variate.'; STYLE=meta,plain VARIATE [VALUES=101...126] X SUBSET [CONDITION=X<111] OLDVECTOR=X; NEWVECTOR=Xs PRINT Xs CAPTION 'Form a subset of a text.' TEXT [VALUES=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z] T SUBSET [CONDITION=X<111] OLDVECTOR=T; NEWVECTOR=Ts PRINT Ts CAPTION 'Form a subset of a factor.' FACTOR [LEVELS=26; VALUES=1...26] F SUBSET [CONDITION=X<111] OLDVECTOR=F; NEWVECTOR=Fs PRINT Fs