BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Caetreviop543
Obsidian | Level 7

 I am trying to create a basic correlation matrix using type = corr. I've looked at multiple sources, and tried adding line numbers (e.g., q28 5-9), length, and formatting statements, but it continues to truncate the last variable. It's worth noting that no matter how many variables I add, it always truncates the last. Q29 prints fine in the datastep below, but if I removed Q30, it would become truncated. 

 

title "Confirmatory Factor Analysis Using the FACTOR Modeling Language";
title2 "Cognitive Data";
data datacorr (type=corr);
infile cards missover;
_Type_ = "corr";
input _Name_ $ q28 q29 q30;
datalines;    
q28  1.00          
q29 -0.30  1.00  
q30 -0.24  0.43  1.00         
;

This is what I see:

 

_Type_    _Name_     q28      q29    q30

corr      q28       1.00     .       . 
corr      q29      -0.30    1.00     . 
corr      q30      -0.24    0.43     1 

It should be 1.00. This is a simple example for illustration; I previously included mean, std, and N, and ran into the same issue. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Nothing has been cut off.

 

You read the last column as a number.  The two number 1 and 1.00 are the exact same number.

 

If you want the values to always display with two decimal places you will have to attach a FORMAT to the variable.

 

So if you attach the format specification 8.2 to the variables

format q28 q29 q30 8.2 ;

Then they will print with 8 characters. 2 of them to right of the decimal point. And one for the decimal point.  The last 5 will be used for the whole number part of the value and any hyphen needed to represent a negative value.  So 8.2 can display values from -9999.99 to 99999.99 .

View solution in original post

2 REPLIES 2
WarrenKuhfeld
Ammonite | Level 13

It is fine as is. If you want the value to be printed as "1.00" then assign a 5.2 format to that column.

Tom
Super User Tom
Super User

Nothing has been cut off.

 

You read the last column as a number.  The two number 1 and 1.00 are the exact same number.

 

If you want the values to always display with two decimal places you will have to attach a FORMAT to the variable.

 

So if you attach the format specification 8.2 to the variables

format q28 q29 q30 8.2 ;

Then they will print with 8 characters. 2 of them to right of the decimal point. And one for the decimal point.  The last 5 will be used for the whole number part of the value and any hyphen needed to represent a negative value.  So 8.2 can display values from -9999.99 to 99999.99 .

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 720 views
  • 0 likes
  • 3 in conversation