The HPREDUCE Procedure
Example 9.3 Output the Correlation Matrix in LIL Format
By using the LIST option in the OUTCP option, you can output a correlation matrix in LIL format.
data one;
array x{2};
do i=1 to 2000;
a=int(ranuni(1)*2);
do j=1 to 2;
x{j}=ranuni(1);
end;
output;
end;
run;
title "Output the Correlation Matrix in LIL format";
proc hpreduce data=one corr outcp=corr_lil/list(eps=0.01);
class a;
reduce unsupervised a x1-x2 /maxsteps=4;
run;
proc print data=corr_lil;
run;
Output 9.3.1 shows the correlation matrix in LIL format.
Output 9.3.1: Output the Correlation Matrix in LIL Format
| Output the Correlation Matrix in LIL format |
| Obs | _TYPE_ | _ID_ | _NAME1_ | _NAME2_ | _VAL_ |
|---|---|---|---|---|---|
| 1 | S | 1 | samples | 2000.00 | |
| 2 | S | 2 | nVar | 3.00 | |
| 3 | S | 3 | nEff | 4.00 | |
| 4 | F | 1 | a | 0 | 979.00 |
| 5 | F | 2 | a | 1 | 1021.00 |
| 6 | M | 3 | x1 | 0.49 | |
| 7 | M | 4 | x2 | 0.50 | |
| 8 | R | 1 | 1 | 1 | 1.00 |
| 9 | R | 2 | 2 | 1 | -1.00 |
| 10 | R | 3 | 2 | 2 | 1.00 |
| 11 | R | 4 | 3 | 1 | 0.03 |
| 12 | R | 5 | 3 | 2 | -0.03 |
| 13 | R | 6 | 3 | 3 | 1.00 |
| 14 | R | 10 | 4 | 4 | 1.00 |
The column _TYPE_ defines the type of each row:
When the _TYPE_ column shows S, the corresponding row contains the statistics of the data set. More specifically, when the _TYPE_ column shows S and the _NAME1_ column shows samples, the _VAL_ column in the corresponding row contains the number of samples in the data set. Similarly, when the _TYPE_ column shows S and the _NAME1_ column shows nVar, the _VAL_ column contains the number of variables. And when the _TYPE_ column show S and the _NAME1_ column shows nEff, the _VAL_ column in the corresponding row contains the number of effects.
When the _TYPE_ column shows F, the row contains the frequency of a level of a CLASS variable. In this case, the _NAME1_ column contains the name of the CLASS variable and the _NAME2_ column contains the name of the corresponding level.
When the _TYPE_ column shows M, the row contains the mean of an interval variable. In this case, the _NAME1_ column contains the name of the variable and the _NAME2_ column is empty.
When the _TYPE_ column shows R, the row contains an entry in the correlation matrix. In this case, the _NAME1_ column contains the row ID, the _NAME2_ column contains the column ID, and the _VAL_ column contains the value.
When the _TYPE_ column shows V or P, the corresponding row contains an entry of a COV matrix or an SSCP matrix, respectively.
Only entries in the lower triangle of the correlation matrix are written to the file, because the correlation matrix is symmetric. Also any entry of the matrix that has a value smaller than 0.01 is ignored in the output (EPS = 0.01), which saves storage space.