BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JasonL
Quartz | Level 8

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.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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)?

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

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)?

--
Paige Miller
JasonL
Quartz | Level 8

Thanks a lot Paige!  The format was in fact $16.  Once I changed it to $18., it displayed all 18 digits.

Tom
Super User Tom
Super User

@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;
JasonL
Quartz | Level 8

Oh I did not know that.  Under what circumstances should $ format be used?  Thanks.

Tom
Super User Tom
Super User

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 6 replies
  • 2481 views
  • 2 likes
  • 3 in conversation