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

## SAS cutting off last column when creating data with input using (type = corr)

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
Super User

## Re: SAS cutting off last column when creating data with input using (type = corr)

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 .

2 REPLIES 2
Rhodochrosite | Level 12

## Re: SAS cutting off last column when creating data with input using (type = corr)

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.

Super User

## Re: SAS cutting off last column when creating data with input using (type = corr)

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 .

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