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
Solution ID:	 	100000190	
Product:	 	SPSS Base 	
Title:
Creating an ASCII Covariance Matrix 
Description:
Q. 
I need to create an ASCII data file containing a covariance matrix. 
How can I do that? 
A. 
The following job shows how to create an ASCII file containing a 
covariance matrix. The first section can be used to generate pseudo- 
random normal deviates to use as a test data set. 
***********************************************************************. 
*** ASCII COVARIANCE MATRIX FOR READING BY OTHER PROGRAM ********. 
***********************************************************************. 
********* CREATE 500 dummy cases of 40 variables each. 
INPUT PROGRAM. 
VECTOR V(40). 
LOOP #I=1 to 500. 
LOOP #I=1 to 40. 
COMPUTE V(#I)=NORMAL(15). 
END LOOP. 
END CASE. 
END LOOP. 
END FILE. 
END INPUT PROGRAM. 
***********************************************************************. 
********************* YOUR WORK STARTS HERE ***************************. 
***********************************************************************. 
******************* GENERATE THE CORRELATION MATRIX *******************. 
CORRELATION /VARIABLES= V1 TO V40 
/MATRIX=OUT (*). 
********* TRANSFORM CORRELATION MATRIX TO COVARIANCE MATRIX ***********. 
MCONVERT. 
***** EDIT THE MATRIX AND DUMP IT INTO A FILE IN 5F16.8 FORMAT ********. 
********* USE AN ALTERNATIVE FORMAT IF YOU SO DESIRE ******. 
DO IF (ROWTYPE_ = 'COV'). 
WRITE OUTFILE = 'ASCIICOV.DAT' RECORDS=8 / 1 V1 to V5 (5F16.8) 
/ 2 V6 TO V10 (5F16.8) 
/ 3 V11 to V15 (5F16.8) 
/ 4 V16 TO V20 (5F16.8) 
/ 5 V21 to V25 (5F16.8) 
/ 6 V26 TO V30 (5F16.8) 
/ 7 V31 to V35 (5F16.8) 
/ 8 V36 TO V40 (5F16.8). 
END IF. 
EXECUTE. 
***** IN MY CASE I HAVE 320 records of five Covariance each ***********. 
Created on: 10/26/2000