help vorter
-------------------------------------------------------------------------------

Title

vorter -- Reorder variables in dataset based on sorted values

Syntax

vorter [+|-] varlist [in #] [, order-options return]

Description

vorter reorders variables in the dataset based on their sorted values in the # observation. If no observation is specified using the in qualifier, the first observation is used. Values are sorted in ascending order if + or nothing is typed in front of varlist, and in descending order if - is typed.

Options

order-options are any options used with order

return does not reorder variables, but only returns the order in r().

Examples

. sysuse auto . list price mpg headroom turn in 1 . vorter price mpg headroom turn

Saved results

vorter saves the following in r():

Macros r(varlist) varlist in current order (reorderd) r(oorder) varlist in original order

Acknowledgments

A first draft of the program appeared as an answer to a question on Statalist posted by Pedro Nakashima.

Author

Daniel Klein, University of Kassel, klein.daniel.81@gmail.com

Also see

Online: order, sort, gsort