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

I'm on SAS version 5.1.


In a database I have a numeric variable called CtrcN whose entries are 14 digit numbers. They are displayed as, for example, 4.2000001E13 instead of 42000001251100.

In order to try to fix this I use the following code.

DATA nameofoutputdatabase;
SET nameofinputdatabse;

(I used an auxiliary variable just to avoid possible issues with writing over the same variable).

The variable CtrcN_Aux still comes looking like 4.2000001E13.

A possible fix to this is to change it into a character variable, but I don't want this. Another one is to define the format in a PROC SQL, which I also do not want to do.

What can I do in order to display the variable as 42000001251100 instead of 4.2000001E13 by using a DATA ; SET ; RUN ;?



Accepted Solutions
Barite | Level 11



try applying the format to the variable: format CtrcN best14.;

View solution in original post

Barite | Level 11



try applying the format to the variable: format CtrcN best14.;

Quartz | Level 8
Perfect. Simple and efficient.
Why isn't my method working, though?
Barite | Level 11

because input is for transforming character variable to numeric format. Your variable is already a numeric variable and if you check

the log you will notice the message:

 Numeric values have been converted to character values at the places given by: (Line):(Column)...


This means your numeric variable used in the function (CtrcN) is converted by sas to a character one using best12. format.


More on input:


Quartz | Level 8
Thank you very much.

Very informative.
Jade | Level 19

Hi @sleretrano,


-- I just notice that Loko has already given the explanation, while I was writing this --


I assume, with "database" you mean "SAS dataset." It was a good idea to store the result of the INPUT function in a new variable, because in general the expression input(CtrcN,BEST14.) returns a different value than CtrcN:

  1. Since the INPUT function expects a character expression as its first argument, the value in CtrcN is automatically converted to a character string (see corresponding NOTE in the log!) using the default numeric format BEST12., which turns 42000001251100 into "4.2000001E13". Please note that the information contained in the last six digits (251100) is already lost at this point!
  2. Reading the string "4.2000001E13" with informat BEST14. results in the number 4.2000001E13, i.e., 42000001000000.


This is not what you want. Instead, don't touch the numeric value and just apply an appropriate format like BEST14. for display purposes, as Loko has suggested. If all the numbers in CtrcN are integers of (up to) 14 digits, format 14. would do as well.


Quartz | Level 8
Thank you. I'm new to SAS, I don't know the standard terminology yet. This was helpful.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 6 replies
  • 1 like
  • 3 in conversation