Merges levels of factors (S.D. Langton).
Options
PRINT = string token |
Controls printed output (summary); default * i.e. none |
|---|---|
OLDFACTOR = factor |
Original factor |
NEWFACTOR = factor |
New factor with merged levels |
Parameters
MERGE = variates or texts |
Levels to merge |
|---|---|
LEVMERGED = variates |
Level to assign to the merged levels |
LABMERGED = texts |
Label to assign to the merged levels |
Description
FACMERGE allows you to merge several levels of a factor into a single level in a new factor. The original factor is specified using the OLDFACTOR option, and the new factor is saved using the NEWFACTOR option.
The levels to merge are specified by the MERGE parameter, and can be identified either by their levels or by their labels. The LEVMERGED parameter can supply a level to use for the merged levels; if this is not specified, the first level of the original factor, in the list of merged levels, is used. Similarly, the LABMERGED parameter can supply a level to use for the merged levels; if this is not specified, the label corresponding to the first merged level is used.
Printed output is controlled by the PRINT option, using the following settings:
summary |
summary of merges. |
|---|
By default, nothing is printed.
Options: PRINT, OLDFACTOR, NEWFACTOR.
Parameters: MERGE, LEVMERGED, LABMERGED.
Action with RESTRICT
The merging process ignores any restrictions but, when this has been completed, any restriction on OLDFACTOR is applied to NEWFACTOR.
See also
Procedure: FACAMEND.
Commands for: Calculations and manipulation.
Example
CAPTION 'FACMERGE example'; STYLE=meta
FACTOR [LEVELS=!(2010...2014); VALUES=12(2010...2014)] Year
FACTOR [LABELS=!t(January,February,March,April,May,June,\
July,August,September,October,November,December);\
VALUES=(1...12)5] Month
FACMERGE [PRINT=summary; OLDFACTOR=Month; NEWFACTOR=Quarter]\
!t(January,February,March),!t(April,May,June),\
!t(July,August,September),!t(October,November,December);\
LEVMERGE=1...4; LABMERGE='January-March','April-June',\
'July-September','October-December'
TABULATE [CLASSIFICATION=Month,Quarter; COUNTS=nobs]
PRINT nobs; FIELD=18