Search code examples
spss

Merging count frequencies SPSS


I am working on a data set that is made up of multiple response questions. I would like to run a count frequency against all the variables and merge the graphs so it will display the percentage of people who checked off the box. I cannot figure out how to get SPSS to do multiple counts and merge the output graphs. Anyone have some insight?

The data set is set up

q1 q2 q3 q4 q5
1  -  1  1  1
1  1  1  1  1
1  1  -  1  1
1  -  -  1  -

So the graph I am trying to out put will have the variables and outputting:

q1==== 100%
q2==    50%
q3==    50%
q4==== 100%
q5===  75%

I have tried merging the responses to one variable but that is resulting in miss aligned data. Can this be achieved through recoding?


Solution

  • To illustrate Jon's and Lanelor's excellent advice, to start with your data;

    data list fixed / q1 TO q5 1-5.
    begin data
    1  111
    11111
    11 11
    1  1 
    end data.
    dataset name mr.
    

    I would typically not keep this as missing data, but recode to zero where a value is absent (this changes how cases are treated in charts - so it does make a difference);

    recode q1 TO q5 (SYSMIS = 0).
    

    Then you can define a mutliple response set and include it in graphs built through the chart builder.

    * Define Multiple Response Sets.
    MRSETS
      /MDGROUP NAME=$qs CATEGORYLABELS=VARLABELS VARIABLES=q1 q2 q3 q4 q5 VALUE=1
      /DISPLAY NAME=[$qs].
    
    *Make the chart - can use chart builder GGRAPH to include multiple response sets.
    GGRAPH
      /GRAPHDATASET NAME="graphdataset" VARIABLES=$qs[name="qs"] COUNT()[name=
      "COUNT"] MISSING=LISTWISE REPORTMISSING=NO
      /GRAPHSPEC SOURCE=INLINE.
    BEGIN GPL
     SOURCE: s=userSource(id("graphdataset"))
     DATA: qs=col(source(s), name("qs"), unit.category())
     DATA: COUNT=col(source(s), name("COUNT"))
     GUIDE: axis(dim(1), label("$qs"))
     GUIDE: axis(dim(2), label("Count"))
     SCALE: cat(dim(1), include("q1", "q2", "q3", "q4", "q5"))
     SCALE: linear(dim(2), include(0))
     ELEMENT: interval(position(qs*COUNT), shape.interior(shape.square))
    END GPL.
    

    Similarly, if creating the table suggested by Lanelor;

    MULT RESPONSE GROUPS=$q1toq5 (q1 q2 q3 q4 q5 (1))
      /FREQUENCIES=$q1toq5.
    

    You can select the desired statistics within the table, and then right-click and produce a chart from those selections (and after the screen shot it includes the chart it produces on my machine with my personal chart template);

    enter image description here

    enter image description here

    GGRAPH and the MRSETS commands are more powerful and allow more customization over the plots, but the suggestion by Lanelor is fine for some quick EDA.