1
votes

I would like to create a correlation matrix as below, but some negative correlation coefficients are missing. Any resolution?

data pain (type=corr);                                                                                     _TYPE_='CORR';                                                                                                  
input _name_ $ p1 -p9 ;                                                                                     
datalines;                                                                                                         
p1 1.0000 ........                                                                                                 
p2 –.0385 1.0000  .......                                                                                          
p3  .6066 –.0693 1.0000  ......                                                                                    
p4  .4507 –.1167  .5916 1.0000  .....                                                                              
p5  .0320  .4881  .0317 –.0802 1.0000   ....                                                                       
p6 –.2877  .4271 –.1336 –.2073  .4731  1.0000  ...                                                                 
p7 –.2974  .3045 –.2404 –.1850  .4138  .6346  1.0000  ..                                                           
p8  .4526 –.3090  .5886  .6286 –.1397 –.1329  –.2599 1.0000  .                                                     
p9  .2952 –.1704  .3165  .3680 –.2367 -.1541  –.2893  .4047  1.000
;
run;
1

1 Answers

2
votes

Did you notice a note about SAS going to a new line, and invalid data messages? You have ........ with no spaces between them for list input, as you are using, this appears to SAS as ONE field. The easiest/best way would be to omit the dots all together and use the INFILE statement option MISSOVER. Also your minus signs are not minus signs I believe you have em-dash '96'x. This program corrects this infile buffer but you could also just fix the data lines.

data pain (type=corr);
   infile cards missover;
   _TYPE_='CORR';
   input @;
   _infile_ = translate(_infile_,'-','96'x);
   input _name_ $ (p1-p9) (??);
   datalines;
p1 1.0000 ........
p2 –.0385 1.0000  .......
p3  .6066 –.0693 1.0000  ......
p4  .4507 –.1167  .5916 1.0000  .....
p5  .0320  .4881  .0317 –.0802 1.0000   ....
p6 –.2877  .4271 –.1336 –.2073  .4731  1.0000  ...
p7 –.2974  .3045 –.2404 –.1850  .4138  .6346  1.0000  ..
p8  .4526 –.3090  .5886  .6286 –.1397 –.1329  –.2599 1.0000  .
p9  .2952 –.1704  .3165  .3680 –.2367 -.1541  –.2893  .4047  1.000
;;;;
   run;

enter image description here