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
* (Q) Need to create a separate HTML file containing a table for each distinc value of Product.

*(A) Posted to SPSSX-L list by Raynald Levesque on 2004/03/30.
* This is a completely automated solution.

DATA LIST LIST /Product (A1) RATING (F2.0) VPoor (PCT2.0) Poor (PCT2.0)
Neutral (PCT2.0) Good (PCT2.0) Excelnt (PCT2.0) Mean (F3.2) N (F5.0) OUTPUT
(A8).
BEGIN DATA
A 1 17 08 33 17 25 3.25 12 Report_A
A 2 17 08 33 17 25 3.25 12 Report_A
B 1 17 08 33 08 33 3.33 14 Report_B
B 2 42 08 08 08 33 2.83 14 Report_B
C 1 17 42 08 08 25 2.83 18 Report_C
C 2 17 17 33 08 25 3.08 18 Report_C
D 1 42 08 17 08 25 2.67 22 Report_D
D 2 17 00 17 42 25 3.58 22 Report_D
END DATA.
VAR LABELS Excelnt 'Excellent' VPoor 'Very Poor'.
SAVE OUTFILE='c:\\temp\\original data.sav'.

SORT CASES BY product.
AGGREGATE OUTFILE=*
	/PRESORTED
	/BREAK=product
	/notused=N.
WRITE OUTFILE='c:\\temp\\macro calls.sps'
	/"!doit prod='"product"'.".
EXECUTE.

*///////////////.
DEFINE !doit (prod=!TOKENS(1))
SET MPRINT=yes.
TEMPORARY.
OMS /SELECT TEXTS
        /IF COMMANDS = ['Report']
        /DESTINATION FORMAT = HTML  OUTFILE = !QUOTE(!CONCAT('C:\\TEMP\\REPORT_',!UNQUOTE(!prod),'.HTM')).
SELECT IF Product=!prod.
Report
  /FORMAT= CHWRAP(ON) PREVIEW(OFF) CHALIGN(BOTTOM)  UNDERSCORE(ON)
  ONEBREAKCOLUMN(OFF) CHDSPACE(1)  SUMSPACE(0)  AUTOMATIC  LIST BRKSPACE(-1)
  PAGE(1) MISSING'.' LENGTH(1, 99999) ALIGN(LEFT) TSPACE(1) FTSPACE(1) MARGINS(1,79)
  /TITLE= CENTER !QUOTE(!CONCAT('Product ',!UNQUOTE(!prod))) RIGHT 'Page )PAGE'
  /VARIABLES
 RATING  (VALUES)  (RIGHT)  (OFFSET(0)) (8)
 Mean  (VALUES)  (RIGHT)  (OFFSET(0)) (8)
 N  (VALUES)  (RIGHT)  (OFFSET(0)) (8)
 Excelnt  (VALUES)  (RIGHT)  (OFFSET(0)) (9)
 Good  (VALUES)  (RIGHT)  (OFFSET(0)) (8)
 Neutral  (VALUES)  (RIGHT)  (OFFSET(0)) (8)
 Poor  (VALUES)  (RIGHT)  (OFFSET(0)) (8)
 VPoor  (VALUES)  (RIGHT)  (OFFSET(0)) (8) .
OMSEND.
SET MPRINT=no.
!ENDDEFINE.
*///////////////.

GET FILE='c:\\temp\\original data.sav'.

INCLUDE 'c:\\temp\\macro calls.sps'.