FAQ/box - CBU statistics Wiki
location: FAQ / box

Clustered boxplots in SPSS

The interactive graphics in SPSS can be accessed from the menu by choosing graphs:interactive. It enables the availability of a greater range of graphics than are present using older, non-interactive graph options. An example is given below in SPSS syntax for one such enhancement: clustered boxplots. Further editing of the graph may be performed by clicking on particular parts of the outputted graph.

[CUT AND PASTE THE SYNTAX IN THE BOX BELOW INTO A SPSS SYNTAX WINDOW AND RUN]

set format f10.5.
Data list free/
Score group  sex.
Begin data
1 1 1
2 1 1
3 1 1
4 1 2
3 1 2
4 1 2
17 2 1
78 2 1
23 2 1
45 2 2
23 2 2
56 2 2
45 3 1
23 3 1
67 3 1
45 3 2
23 3 2
12 3 2
end data.

DEFINE !BOX (!POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !TOKENS(1)
                     / !POS !CMDEND).


VAR LABELS      !1      !4/
                           !2      !5/  
                           !3      !6/.

VALUE LABELS    !2        (1) !7
                                              (2) !8
                                              (3) !9
                                              (4) !10
                                              (5) !11/
                             !3         (1)  !12
                                             (2) !13
                                             (3) !14
                                             (4) !15
                                             (5) !16/.
IGRAPH /VIEWNAME='Boxplot' /X1 = VAR(!2) TYPE = CATEGORICAL /Y = VAR(!1)
  TYPE = SCALE  /STYLE = VAR(!3) /COORDINATE = VERTICAL  /X1LENGTH=3.0
 /YLENGTH=3.0 /X2LENGTH=3.0 /CHARTLOOK='NONE' /CATORDER VAR(!4) (ASCENDING
  VALUES OMITEMPTY) /CATORDER VAR(!2) (ASCENDING VALUES OMITEMPTY) /BOX
  OUTLIERS = ON EXTREME = ON MEDIAN = ON WHISKER = T.
EXE.
!ENDDEFINE.

* can pad out labels with as many * as required

* The line below can be adapted as required for specific data to * specify variable column names and their labels in the boxplot, * number of levels of each categorical variable and the names of * these levels to appear in the boxplot. It is set up for the 
* example data above. In the line below asterisks denote levels 
* of variables which are not present.
!BOX score group sex score gp gender BLACK WHITE OTHERS * *  M F * * *.

* Multiple invocations of the macro in the same interactive session will produce the following note:

>The macro name specified on the DEFINE command duplicates the name of a previously defined macro. This instance will take precedence.

This warning does not indicate a problem and may be ignored.

None: FAQ/box (last edited 2013-03-08 10:18:09 by localhost)