Order variables

Is it driving you crazy that variables are ordered in an illogical way? This can be fixed by using order.

When using order, you must specify which variables you want to move.

First, we will show you how to move one variable (works also for more than one specified variable), then we show how to re-order the whole list of variables. This works also for portions of the list.

Move the variable to the beginning of the dataset

order varname, first

For example:

order id, first

Move the variable to the end of the dataset

order varname, last

For example:

order mortality, last

Move the variable before another variable

order varname1, before(varname2)

For example:

order health_2007, before(health_2008)

Move the variable after another variable

order varname1, after(varname2)

For example:

order phystest2, after(phystest1)

Order the variables alphabetically

order _all, alpha

or

order firstvarname-lastvarname, alpha

For example:

order id-mortality, alpha

Order a portion of the variable list alphabetically:

order phystest1-phystest10, alpha
More information
help order