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
* Regression with normed weight.

* Raynald Levesque January 2003.

DATA LIST LIST /race gender age region wgt.
BEGIN DATA
1 1 1 1 150
1 2 1 1 200
1 1 2 1 170
1 2 2 1 230
1 1 1 2 180
1 2 1 2 210
1 1 2 2 150
1 2 2 2 240
2 1 1 1 120
2 2 1 1 250
2 1 2 1 140
2 2 2 1 210
2 1 1 2 190
2 2 1 2 200
2 1 2 2 100
2 2 2 2 200
END DATA.
LIST.
SAVE OUTFILE='c:\\temp\\my data.sav'.


*///////////////.
DEFINE !regres(criter=!CMDEND)

GET FILE='c:\\temp\\my data.sav'.
SELECT IF !criter.

SAVE OUTFILE='c:\\temp\\temp data.sav'.
COMPUTE nobreak=1.
AGGREGATE OUTFILE=*
	/PRESORTED
	/BREAK=nobreak
	/n=N /totweigt=SUM(wgt).
WRITE OUTFILE='c:\\temp\\norm syntax.sps' 
	/'DEFINE !n()'n'!ENDDEFINE.'
	/'DEFINE !w()'totweigt'!ENDDEFINE.'.
EXECUTE.
INCLUDE 'c:\\temp\\norm syntax.sps'.

GET FILE='c:\\temp\\temp data.sav'.
COMPUTE normwt=!n * wgt / !w.
DESCRIPTIVES
  VARIABLES=normwt
  /STATISTICS=MEAN .
WEIGHT BY normwt.

*.
* Do your regression here.
*.

!ENDDEFINE.
*///////////////.

* Test macro.
!regres criter=(gender=1 & race=2).
!regres criter=(gender=2 OR race=1).

* The average of normwt is 1 in both cases.