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.

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!

SAS Enterprise Guide vs. SAS Studio

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.

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