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):
You can create a frequency chart by completing the following dialog:
This will result in the following graph:
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:
You select the variable Country and click the Properties button. This will give the following dialog:
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.
Click in the cells in the Label column to change the codes into country names:
Now select the category of which you want to change the order and click the and buttons to change the order.
Proceed in the same way to bring France to the top of the list.
Now return to the Frequencies bar chart dialog:
The new graph looks like this: