2016-11-14 62 views
1

下面的循環無法正確創建任何交互項(即互相乘法的新變量)。我不完全確定如何正確指定x(#j + #i),所以也許這就是搞砸了東西。使用循環在SPSS中創建交互

DATA LIST LIST/  A1L1 A1L2 A1L3 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10. 
BEGIN DATA              
1 0 0 1 0 0 0 0 0 0 0 0 0  
1 0 0 0 1 0 0 0 0 0 0 0 0  
0 1 0 0 0 1 0 0 0 0 0 0 0  
0 1 0 0 0 0 1 0 0 0 0 0 0  
0 0 1 0 0 0 0 1 0 0 0 0 0  
0 0 1 0 0 0 0 0 1 0 0 0 0  
-1 -1 -1 0 0 0 0 0 0 1 0 0 0  
-1 -1 -1 0 0 0 0 0 0 0 1 0 0  
-1 -1 -1 0 0 0 0 0 0 0 0 0 1  
END DATA.              
LIST.              

vector A1L1P A1L2P A1L3P (10). 
vector x = A1L1P1 to A1L3P10. 
VECTOR ASC = P1 to P10. 
VECTOR EcLvl = A1L1 to A1L3. 
LOOP #j = 1 to 3. 
    LOOP #i = 1 to 10. 
     COMPUTE x(#j + #i) = (ASC(#i) * EcLvl(#j)). 
    END LOOP. 
END LOOP. 
EXECUTE. 

回答

0

而不是

COMPUTE x(#j + #i) = (ASC(#i) * EcLvl(#j)). 

我想你想

COMPUTE x(10*(#j-1) + #i) = (ASC(#i) * EcLvl(#j)).