1. Home
  2. FACEXCLUDEUNUSED procedure

FACEXCLUDEUNUSED procedure

Redefines the levels and labels of a factor to exclude those that are unused (R.W. Payne).

No options

Parameters

FACTOR = factors Factors with unused levels
NEWFACTOR = factors New factors, with levels (and labels) that exclude those that are unused; if unset, the original factor is redefined

Description

FACEXCLUDEUNUSED allows you to redefine a factor to remove levels that do not occur within its current values. This can be useful, for example, if you want to produce tables that are not cluttered with empty rows or columns.

The factor is specified by the FACTOR parameter, and a new factor (excluding the unused levels) can be saved by the NEWFACTOR parameter. If NEWFACTOR is not set, the original factor is redefined with the new levels (and labels, if any).

Options: none.
Parameters: FACTOR, NEWFACTOR.

Action with RESTRICT

Any restrictions are ignored.

See also

Procedures: FACAMEND, FACLEVSTANDARDIZE, FACSORT, FACUNIQUE.
Commands for: Calculations and manipulation.

CAPTION  'FACEXCLUDEUNUSED example'; STYLE=meta
VARIATE  [NVALUES=15] Quantity,Charge
FACTOR   [NVALUES=15; LABELS=!T(A,B)] Type
&        [LABELS=!T(Aberdeen,Birmingham,Bristol,Coventry,Durham,Hull,\
         London,Manchester,Nottingham,Plymouth,Reading,Swansea)] Town
READ     [PRINT=data,errors] Town,Quantity,Type; FREPRESENTATION=labels
    London 10 A  Manchester   5 B  Birmingham  10 B     Bristol 25 A  
Manchester 10 A  Birmingham 100 B      London 200 B  Manchester 25 A  
   Bristol 50 A  Birmingham  25 A     Bristol  25 B      London 25 A 
    London 50 B  Manchester  25 B      London  50 A  :
TABULATE [PRINT=totals,nobservations; CLASSIFICATION=Town,Type] Quantity
" remove towns with no data "
FACEXCLUDEUNUSED Town
TABULATE [PRINT=totals,nobservations; CLASSIFICATION=Town,Type] Quantity
Updated on September 12, 2019

Was this article helpful?