3

I have a categorical variable that takes values 0-8. Each of these values are labelled with their respective category.

When I try to make a histogram, I get 0-8 in the x axis instead of the value labels. I have been looking for an hour both online and on google for a solution with no result. All I could find was how to add labels to pivottables or frequency tables or how to add "data labels" to histograms, which just shows the frequency on the histogram.

Any help would be greatly appreciated.

DATASET ACTIVATE DataSet1.
FREQUENCIES VARIABLES=c1_gemeente_woon_nu_name c1_leeftijd s1_nhuishoudensleden s1_opleiding NA 
    s1_geslacht s1_huishoudensinkomen s1_bezigheid_nu
  /HISTOGRAM
  /ORDER=ANALYSIS.
OUTPUT MODIFY
  /SELECT TABLES
  /IF COMMANDS=["Frequencies(LAST)"] SUBTYPES="Frequencies"
  /TABLECELLS SELECT=[VALIDPERCENT CUMULATIVEPERCENT] APPLYTO=COLUMN HIDE=YES
  /TABLECELLS SELECT=[TOTAL] SELECTCONDITION=PARENT(VALID MISSING) APPLYTO=ROW HIDE=YES
  /TABLECELLS SELECT=[VALID] APPLYTO=ROWHEADER UNGROUP=YES
  /TABLECELLS SELECT=[PERCENT] SELECTDIMENSION=COLUMNS FORMAT="PCT" APPLYTO=COLUMN
  /TABLECELLS SELECT=[COUNT] APPLYTO=COLUMNHEADER REPLACE="N"
  /TABLECELLS SELECT=[PERCENT] APPLYTO=COLUMNHEADER REPLACE="%".

Specifically the s1_bezigheid_nu is the one in question that needs to have the value labels in the histogram.

enter image description here

Victor Nielsen
  • 443
  • 2
  • 14

1 Answers1

0

A histogram is usually used for continuous variables, so many different values are binned together to create each bar in the histogram. What you should be using for a categorical variable with a small number of categories is a bar chart. A bar chart will give you by default a count of each category - with the label of the category.
If you insist on a histogram, you should use the histogram in the chart builder facility rather than the histogram option in the frequencies command. The chart builder is more sofisticated and will put the labels in the histogram (like in a bar chart).
To get to the chart builder: GRAPHS => CHART BUILDER

eli-k
  • 10,898
  • 11
  • 40
  • 44