Separate box plot graph for each category value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | *(Q)I have test scores for 90 high schools, and I want SPSS to produce a different boxplot for each school, so that there is one boxplot per graph, 90 graphs, and the graph for each school prints on a different sheet of paper. I want to run it as a batch job. I can do that using the following syntax: GET FILE='D:\\DDrive\\ADoc\\Board\\SchoolsCPS\\Data\\Ap\\test.sav'. SORT CASES BY school (A) . SPLIT FILE SEPARATE BY school . EXAMINE VARIABLES=rge BY grade /PLOT=BOXPLOT /STATISTICS=NONE/NOTOTAL /MISSING=REPORT. However, when I consult the Command Reference Guide, I find that PLOT provides very limited control of the graph. When I look at I/BOX, I find some of the controls I'm looking for. I still don't find controls for things like tic marks. If I try to use IGRAPH instead of EXAMINE.../PLOT, I don't get the separate graph for each school. Is there a solution? *********************************************. *(A) by rlevesque@videotron.ca on 2001/10/06. ********************************************* GET FILE='c:\\program files\\spss\\employee data.sav'. SET MPRINT=no /PRINTBACK=listing. */////////////////////////////. DEFINE !ibox1(cat=!TOKENS(1) /var1=!TOKENS(1) /var2=!TOKENS(1)) AUTORECODE !cat /INTO cat$. COMPUTE dummy=1. SAVE OUTFILE='c:\\temp\\mydata.sav'. AGGREGATE /OUTFILE=* /BREAK=dummy /NbCat = MAX(cat$). WRITE OUTFILE='c:\\temp\\syntax.sps' /'DEFINE !nbcat()',NbCat,'!ENDDEFINE.'. EXECUTE. INCLUDE FILE='c:\\temp\\syntax.sps'. !ibox2 var1=!var1 var2=!var2. !ENDDEFINE. */////////////////////////////. * A second macro is used to ensure that the macro created by the ibox1 is available to ibox2. */////////////////////////////. DEFINE !ibox2 (var1=!TOKENS(1) /var2=!TOKENS(1)) !DO !cat=1 !TO !EVAL(!nbcat) GET FILE='c:\\temp\\mydata.sav'. SELECT IF cat$=!cat. IGRAPH /VIEWNAME='Boxplot' /X1 = VAR(!var2) TYPE = CATEGORICAL /Y = VAR(!var1) TYPE = SCALE /COORDINATE = VERTICAL /X1LENGTH=3.0 /YLENGTH=3.0 /X2LENGTH=3.0 /CHARTLOOK='NONE' /CATORDER VAR(!var2) (ASCENDING VALUES OMITEMPTY) /BOX OUTLIERS = ON EXTREME = ON MEDIAN = ON WHISKER = T. !DOEND !ENDDEFINE. */////////////////////////////. SET MPRINT=yes. !ibox1 cat=jobcat var1=salary var2=minority. * In your particular case, you would call the macro using the following line. !ibox1 cat=school var1=rge var2=grade. |
Related pages
...
Navigate from here