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
Rhodochrosite | Level 12

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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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