1. Home
  2. QFACTOR procedure

QFACTOR procedure

Allows the user to decide to convert texts or variates to factors (R.W. Payne).


PRINT = string tokens Controls printed output (replication, summary); default summ
MAXCATEGORY = scalar Maximum number of distinct values that a VECTOR may contain if it is to be converted; default 10
QUERY = string token Whether to ask the user if each VECTOR with no more than MAXCATEGORY distinct values is to be converted


VECTOR = variates or texts Vectors to be converted into factors


The QFACTOR procedure provides a convenient way of converting variates or texts to factors. The variates or texts are specified by the VECTOR parameter. The MAXCATEGORY option defines the maximum number of distinct values that each VECTOR may contain if it is to be converted (default 10). The QUERY option determines whether to ask the user whether to convert each VECTOR that has no more than MAXCATEGORY categories; with the default setting, QUERY=no, they are all converted.

The PRINT option controls printed output, with settings:

    replication to print the replication of the levels of each converted VECTOR;
    summary to print the number of values and levels of each converted VECTOR or, alternatively, a comment to say that the VECTOR has not been converted.


Parameter: VECTOR.


The QUESTION procedure is used to obtain the user’s decision, and the GROUPS directive is used to convert the variate or text to a factor.

See also

Directive: QDIALOG.

Procedures: QLIST, QUESTION.

Commands for: Program control, Calculations and manipulation.


CAPTION      'QFACTOR example'; STYLE=meta
VARIATE      [VALUES=2(1...8)] V1
VARIATE      [VALUES=2(1...12)] V2,V3
QFACTOR      V1,V2
&            [MAXCATEGORY=15] V3
GETATTRIBUTE [ATTRIBUTE=stype,levels] V1,V2,V3; SAVE=typev1,typev2,typev3
PRINT        typev1[]
&            typev2[]
&            typev3[]
TEXT         [VALUES=2(a,b,c,d,e,f,g,h)] T1
TEXT         [VALUES=2(a,b,c,d,e,f,g,h,i,j,k,l)] T2,T3
QFACTOR      [PRINT=summary,replication] T1,T2
&            [MAXCATEGORY=15] T3
GETATTRIBUTE [ATTRIBUTE=stype,levels,labels] T1,T2,T3;\
PRINT        typet1[]
&            typet2[]
&            typet3[]
Updated on March 6, 2019

Was this article helpful?