Steve Scher
Steve Scher

Reputation: 172

Multiple Variables on a Frequency Chart (SPSS)

I have a series of 16 nominal variables (T/F questions). I need to produce a bar chart that includes the frequency of each option for each of the questions. (In other words, there should be 32 bars in the graph: how many people said True & how many people said False for each of the 16 questions).

I need it to be done with syntax, but I can't even make the SPSS Chart Builder do this so I can copy the syntax it generates.

Any help appreciated.

Data layout: enter image description here

Upvotes: 1

Views: 195

Answers (1)

eli-k
eli-k

Reputation: 11360

Don't work much with SPSS charts myself but I think you can get the effect you want by restructuring the data instead of the chart. The following restructure command gets you the TF variables as one category column instead or separate columns:

varstocases /make TF from TF_1 to TF_16/index=vr(TF).

Now you can chart th "vr" variable and use "TF" for clustering. This is the syntax pasted from the chart builder:

GGRAPH
  /GRAPHDATASET NAME="graphdataset" VARIABLES=vr COUNT()[name="COUNT"] TF MISSING=LISTWISE 
    REPORTMISSING=NO
  /GRAPHSPEC SOURCE=INLINE.
BEGIN GPL
  SOURCE: s=userSource(id("graphdataset"))
  DATA: vr=col(source(s), name("vr"), unit.category())
  DATA: COUNT=col(source(s), name("COUNT"))
  DATA: TF=col(source(s), name("TF"), unit.category())
  COORD: rect(dim(1,2), cluster(3,0))
  GUIDE: axis(dim(3), label("vr"))
  GUIDE: axis(dim(2), label("Count"))
  GUIDE: legend(aesthetic(aesthetic.color.interior), label("TF"))
  GUIDE: text.title(label("Clustered Bar Count of vr by TF"))
  SCALE: linear(dim(2), include(0))
  ELEMENT: interval(position(TF*COUNT*vr), color.interior(TF), shape.interior(shape.square))
END GPL.

Upvotes: 0

Related Questions