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
* QUESTION:
	I have a large data set where we want to look at the interaction
	between two nominal variables (4 categories and 12 categories) within a
	regression context. Is there a way of getting SPSS to produce the 33 terms
	((4-1)X(12-1)).

* ANSWER posted by David Matheson (from SPSS) to SPSSX-L list on 2001/04/06;
	In the code below, I'm supposing that the variable a is your 4-level
	variable and b is your 12-level variable. I'm also supposing that you're
	using indicator coding with the last category of each as the reference
	category. Alterations from this, such as effect coding (where the reference
	category code for each dummy variable is -1, rather than 0) will take a
	little more work.
*	You'll need to replace a and b with your own variable names in the logical
	expression in the second COMPUTE command.


* sample data.
DATA LIST LIST /a b.
BEGIN DATA
1 1
2 2
3 3
4 4
1 5
2 6
3 7
4 8
1 9
2 10
2 11
3 12
END DATA.
LIST.

* Produce the interaction terms.
vector a1b a2b a3b  (11) .
vector x =  a1b1 to a3b11 .
loop #i = 1 to 3.
compute #k = (#i-1)*11.
loop #j = 1 to 11 .
compute x(#k + #j) = ((a = #i) & (b= #j)) .
end loop.
end loop.
execute.