Graphing one categorical variable with SPSS

1200 US college students were surveyed about their gender preference when making friends. They were asked the quesiton: "With whom do you find it easiest to make friends?" [1]

The resulting dataset contains 1200 cases and one variable:

• Friends (including 3 possible values: Opposite sex, Same sex, No difference)

Dataset

• friends.xls
• an SPSS version of the dataset is available on your class website: friends.sav

Open the dataset in the SPSS data editor.

The following instructions are based on the student version of PASW (SPSS) version 18.

Create a table of counts

Use the Frequencies analysis to create a table of counts and percents:

• Click Analyze > Descriptive Statistics > Frequences.

The Frequencies dialog displays.

• Move the "Friends" variable from the lefthand box to the Variables box.

Although you could create the charts along with the frequencies, instructions for doing so using the Chart Builder are provided below.

• Click OK.

Create a pie chart

Use the Chart Builder to create a pie chart:

• Click Graphs > Chart Builder....
• Note that the variables in friends.sav are appropriately defined; click OK in the Chart Builder warning dialog, if it displays.

The Chart Builder dialog box displays:

• In the Gallery area at the bottom of the box, select Pie/Polar from the listing.
• Select the picture of the pie chart and drag it to the large chart preview window.

A crude preview displays and the Element Properties window opens.

• Continuing in the Chart Builder dialog, click and drag the "Friends" variable (from the list on the left) to the Slice by? box at the bottom of the preview window.

Don't worry that the preview graph fails to represent your data. The preview is based on example data.

A basic pie chart is now ready to be created.

• At the bottom of the Chart Builder dialog box, click OK.

The Chart Builder dialog box closes and SPSS activates the Output window to display the pie chart.

Adding titles and labels to the pie chart

To make adjustments to the resulting pie chart, double-click the graph displayed in the output window.

The Chart Editor displays, which includes many options for customizing a graph.

To add a title:

• Select Options > Title.

A title is added to the graph with the word "Title".

• Click on the word "Title" to highlight the title box; click on the word "Title", again, to begin editing.
• Enter the title text.
• Press enter on your keyboard to add the title to the graph.

To add count and percent labels on each slice:

• Select Elements > Show Data Labels.

A Properties box displays.

• Select the Data Value Labels tab from the tab bar at top.
• Move the elements from Not Displayed: to Displayed, as desired. For example, a useful label for a slice might indicate the value of the variable, the count and the percent.
• Reorder the labels as desired.
• Click Apply.

If you include the variable values in the labels, you may wish to remove the legend:

• Select Options > Hide Legend.

Close the Chart Editor, the changes are applied to the graph in the output window.

Notes

1. Adapted from Open Learning Initiative. Probability and Statistics: One categorical variable to provide instructions for doing the analyses using SPSS.