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
* I have 30 schools. When I use split file, I get 30 Freq tables, then 30 Histograms, etc.
* What I want is all results for school 1, then all results for school 2, etc.

* Answer by rlevesque@videotron.ca.

*Define some data for illustration purposes.
DATA LIST FREE /school score.
BEGIN DATA
1 19 1 14 1 29 1 20 
2 13 2 24 2 24 2 22 
3 20 3 34 3 27 3 25 
4 40 4 44 4 22 4 26 
END DATA.
LIST.

*Define a macro to do the job.
*//////////////////////.
DEFINE !doit().
!DO !sch=1 !TO 4.
COMPUTE filter_=(school=!sch).
FILTER BY filter_.
* replace next graph and Summarize by what is needed.
GRAPH 
	/TITLE=!QUOTE(!CONCAT('Histogram for school no ',!sch))
	/HISTOGRAM=score .
SUMMARIZE
  /TABLES=score
  /FORMAT=NOLIST TOTAL
  /TITLE=!QUOTE(!CONCAT('Case Summaries for school no ',!sch))
  /MISSING=VARIABLE
  /CELLS=COUNT MEDIAN VAR .
FILTER OFF.
!DOEND
!ENDDEFINE.
*//////////////////////.

*Call macro.
!doit.