help sortmean

Title

sortmean -- List of variable names sorted by their means

Syntax

sortmean [varlist]
[if] [in]
[weight]
[,
allobs
descending
local(macname)
]

fweights and aweights are allowed.

Description

sortmean sorts the names of numeric variables in
varlist by their means, displays the list of variable names, and
produces a local macro (by default called sortlist) accessible to
the user.

If varlist is not specified, it defaults to all variables
in the dataset. Otherwise one or more variables may be specified.

Any string variables specified will be ignored, either with or
without an explicit varlist.

Options

allobs specifies that observations with any missing
values on varlist will be included. The default is to ignore them.

descending specifies that variable names are to be sorted
in descending order, the variable with highest mean first. The default is to
sort in ascending order.

local() specifies an alternative name for the local macro
produced.

Examples

. sysuse auto, clear

. sortmean weight mpg price

. sortmean weight mpg price, desc

. di "`sortlist'"

. separate mpg, by(rep78)

. sortmean mpg?, allobs

. sortmean mpg?, allobs desc

. tabstat `sortlist', c(s)

Author

Nicholas J. Cox, Durham University, UK

n.j.cox@durham.ac.uk

Acknowledgments

Daniel Klein gave a kindly reminder about his vorter command on
SSC, which can do something similar, and much more, and gave helpful
suggestions about the Mata code for this command.

Also see

Online:
vorter (SSC; if installed)