SPSS Instructions for Making a Histogram SPSS Instructions for Creating Density Histograms
I assume that your data are already read into SAS, as was described in
the document for reading in data. I will also assume that we want to
draw the histogram for the log blood leads.
-
1. You can make
a histogram of log blood lead by selecting the graph menu, selecting
histogram, highlighting the lblood variable, and clicking the arrow,
and clicking OK.
-
2. In the class notes, I broke lead levels down by renter status. To get
home owners, go to the Data menu, select "Select cases ...", select "If
condition is satisfied, click the "If" box, and in the box type "rent=0".
(You can do this with the little menu editor, but this is pointless.)
Leave the radio buttons for "Unselected cases are" at "filtered".
Click "OK". You can go back to look at your data by clicking the button
that looks like a spread sheet. Notice that the row indicators for
most of the observations have a slash through them indicating that they
aren't included in calculations right now. Go back to the graph menu,
select histogram. The lblood should still be selected for the histogram.
click "ok" to get a new histogram. This histogram is based on only 38
observations, since there are only 38 home owners.
-
3. In class, I drew histograms of blood lead rather than log blood lead.
We'll do this now.
- a. Create the transformed variable by selecting the transform
menu, and choosing compute. Type blood in the target variable box, and
"exp(lblood)" in the box after the equal sign. Click OK. You did exp
because you had logs and wanted the original variables, and exp is the
inverse of log. If you go back to the spreadsheet icon, you will see
that the spread sheet now has an additional column headed "blood".
- b. Now again select histogram from the graph menu. lblood should
still be in the variable box. Note that the arrow now faces out of
the box. Click the arrow to empty the box, select blood, and click the
arrow to put blood into the variable box. Hit ok.
- 1. Make a column of data consisting of frequencies. I named
these "count".
- 2. Go to the variable view tab of the data editor, and click on
the type box of second row. You'll see a gray part with some dots.
Click on this, and you'll get a menu of data types. Select string at
the bottom, and hit OK.
- 3. Go back to the data view, and type in the ranges in the second
column.
- 4. Make a new column of data consisting of densities, by dividing
your original frequencies by the freqency total, and then by the bin
widths. To do this,
- a. first multiply the the count total by the bin size. (The most convenient way to do this is by hand, and not with SPSS).
- b. Do Transform->Compute,
- c. type the variable name for the density (I call it density) in the
target variable box.
- d. type "count/", followed by the product you just computed, in the numeric expression box.
- e. Hit OK.
- 5. Do Graphs->Barplot, select Simple, near the bottom select the
button for "Values of Individual Cases", and hit Define. You'll get a
dialog box, with all of your variables on the left, and a box marked "Bars
Represent" in the middle. If the "Bars Represent" box has anything in it,
highlight it and click the arrow to remove it. Highlight density in the
box on the left, and hit the arrow to put it into the bars represent box.
Go to the "Category labels" box, select "Variable", highlight the variable
in which you put the ranges. Hit OK.
- 6. Now go to the output, and double click on the graph. This will
open a window in which to edit the graph. In this window, double click
on a bar. A box marked "Properties" will open. In the tab marked
"Bar Options", you'll see a slider marked "Bars". Move it to 100%,
all the way to the right. Hit apply.
Back to course page