Show menu

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):

Reorder a categorical variable

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

Reorder a categorical variable

This will result in the following graph:

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:

Reorder a categorical variable

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

Reorder a categorical variable

In this dialog 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.

Reorder a categorical variable

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

Reorder a categorical variable

Now select the category of which you want to change the order and click the Up button and Down button buttons to change the order.

Reorder a categorical variable

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

Reorder a categorical variable

Now return to the Frequencies bar chart dialog:

Reorder a categorical variable

The new graph looks like this:

Reorder a categorical variable

Share on Facebook Share on Twitter

This site uses cookies to store information on your computer. More info...