In using the SAS EG this morning, I'm seeing only 16 digits of a column that is 18 digits long with 18 digits of characters in all records. When I exported the dataset to Excel, I got all 18 digits. Why and how can I display all the digits properly? Thanks.
Is this a numeric variable or a character variable? (Just because it is digits, it can still be a character variable according to SAS)
What is the format on this variable in SAS?
Have you expanded the column (by dragging the right boundary of the column further to the right)?
Is this a numeric variable or a character variable? (Just because it is digits, it can still be a character variable according to SAS)
What is the format on this variable in SAS?
Have you expanded the column (by dragging the right boundary of the column further to the right)?
Thanks a lot Paige! The format was in fact $16. Once I changed it to $18., it displayed all 18 digits.
@JasonL wrote:
Thanks a lot Paige! The format was in fact $16. Once I changed it to $18., it displayed all 18 digits.
This is why I consider it standard practice to NOT attach $ format to character variables. SAS does not need it since it knows how to display character strings and if you attach too short (or even too wide) a format to a character variable it can cause confusion.
data want;
set have;
format _character_;
run;
Oh I did not know that. Under what circumstances should $ format be used? Thanks.
You might use the $ format when using a formatted style PUT statement. For example to make it easier to create a fixed column report.
You might use the $ format in a procedure like PROC FREQ to have the data grouped by the beginning characters in the value.
proc freq data=sashelp.class;
tables name ;
format name $1. ;
run;
Similar for numeric variables you do not need to attach a format permanently to the variable when you make the dataset. SAS knows how to display numbers also. But in the case of numeric variable SAS will in general use the BEST12. format to display the values. So if you have large integers you might want to use a format to prevent if from switching to scientific notation and and not showing all of the digits. Or if have non integer values you might want to attach a format have a consistent number of decimal places displayed.
Ok thanks.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.