*! version 0.31

Title

egen marktop -- collapsing a categorical variable

Syntax

egen
newvar
= marktop(oldvar)
[,
options]

Optional
top(#) Keep top most frequent. Default value is 5

singles(numlist) A numlist of oldvar values to keep
as singles

other(string) String label for the categori of the remaining
values. Default value is "other"

replace Replace newvar if it exists

Description

A categorical variable is collapsed into a new variable newvar
keeping the top most frequent and/or a subsample of oldvar values as
single values while collapsing the remaining values into one value with label
other.

Authors and support

Author:

Niels Henrik Bruun,

Aalborg University Hospital

Support:

niels.henrik.bruun@gmail.com