04-13-2016 06:53 AM
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.
(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 ;?
04-13-2016 07:11 AM
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:
04-13-2016 07:26 AM - edited 04-13-2016 07:27 AM
-- 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:
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.
Need further help from the community? Please ask a new question.