How to reorder a categorical variable

Suppose you have the following categorical data, with 2-digit codes representing some European countries (DE: Germany, FR: France, NO: Norway, SE: Sweden, O: Other):

How to reorder a categorical variable

You can create a frequency chart by completing the following dialog:

How to reorder a categorical variable

This will result in the following graph:

How to reorder a categorical variable

Now we want to:

  • Replace the 2-digit country codes with the full country names
  • Change the order of the countries so that the countries appear alphabetically with the Others bar at the utmost right.

We proceed as follows.

Select Edit variables list in the tools menu to obtain the following dialog:

How to reorder a categorical variable

You select the variable Country and click the Properties button. This will give the following dialog:

How to reorder a categorical variable

In this diaglog you can assign labels to the different categories and define their order.

Click Scan data to scan the data and to populate the list with existing values.

How to reorder a categorical variable

Click in the cells in the Label column to change the codes into country names:

How to reorder a categorical variable

Now select the category of which you want to change the order and click the How to reorder a categorical variable and How to reorder a categorical variable buttons to change the order.

How to reorder a categorical variable

Proceed in the same way to bring France to the top of the list.

How to reorder a categorical variable

Now return to the Frequencies bar chart dialog:

How to reorder a categorical variable

The new graph looks like this:

How to reorder a categorical variable