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.
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 .
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.
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 .
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.
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.
Ready to level-up your skills? Choose your own adventure.