Daniel
Daniel

Reputation: 3711

How to create a clustered bar chart with two nominal variables on the x axis?

Assume there are three nominal variables, A, B and C.

It is easy enough to produce a clustered bar chart with two of them: one, e.g. A, goes into the "X-Axis" and one into the "Cluster on X", e.g. Z.

There are also 3-D versions of this where one can add a "Z-Axis" and use a third nominal variable. But those are very hard to read since some bars will be hidden behind others.

Is there a way to create a 2-D clustered bar chart which groups two nominal variables on the "X-Axis". So say, I want to have variable A and B on the "X-Axis". So I would like to have for each value of A a clustered bar chart with each value of B. For example, say A is sex (say male and female) and B is eye color (say brown, green, blue). Then I would like to have for male a bar with all the male brown eyed, male green eyed, and male blue eyed. And right next to it in the same chart should be the next group of females: female brown eyed, female green eyed, female blue eyed.

Upvotes: 0

Views: 188

Answers (1)

rabidotter
rabidotter

Reputation: 31

If we assume the following...

sex (0=male, 1=female) eye (0=brown, 1=green, 1=blue)

...something like this should work, as it combines the two variables into one named sexeye:

IF sex=0 AND eye=0 sexeye=1 /*Male brown eyes.
IF sex=0 AND eye=1 sexeye=2 /*Male green eyes.
IF sex=0 AND eye=2 sexeye=3 /*Male brown eyes.
IF sex=1 AND eye=0 sexeye=4 /*Female brown eyes.
IF sex=1 AND eye=1 sexeye=5 /*Female green eyes.
IF sex=1 AND eye=2 sexeye=6 /*Female brown eyes.

VARIABLE LABELS sexeye'Combined sex and eye color'.
ADD VALUE LABEL sexeye 1 'Male brown eyes.' 2 'Male green eyes.' 3 'Male blue eyes.' 4 'Female brown eyes' 5 'Female green eyes' 6 'Female brown eyes'.
EXECUTE.

Now you have one variable where you previously had two.

Upvotes: 0

Related Questions