Merges levels of factors (S.D. Langton).
|Controls printed output (
||New factor with merged levels|
||Levels to merge|
||Level to assign to the merged levels|
||Label to assign to the merged levels|
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
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
||summary of merges.|
By default, nothing is printed.
The merging process ignores any restrictions but, when this has been completed, any restriction on
OLDFACTOR is applied to
Commands for: Calculations and manipulation.
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