Hi,
We notice SAS base will round the figure is more than 18 digit.
Is there any setting in server/client machine if we want to programme to show exact value?
Please advice. Thank you.
Below is the sample code:
data test;
format b best32.;
format d best32.;
format f best32.;
x = '0010000000130000123';
y = '001000000013000012';
z = '00100000001300001';
len1 = length(x);
len2 = length(y);
len3 = length(z);
b = input(x, best32.);
d = input(y, best32.);
f = input(z, best32.);
run;
Regards,
Senico
Jaap Karman gave you the right reference material. Let me give you the short answer.
No, it's not possible. The way that SAS stores numeric values, it has room to store only 15 to 16 significant digits (ASCII vs. EBCDIC). If you want an accurate representation of longer values, you will have to print the character variable instead.
There are exceptions. If you experiment with numbers that are multiple of 8, for example, you will see that you can store more significant digits. However, understanding why requires reading up on the reference material that you'll find in Jaap's link.
Good luck.
I'n not following you. What do mean by round?
What your example shows is that leading zeros is not displayed by default.
If you want leading zeros on numerical variable, use Zn. format.
Hi,
Let me provide you simple example:
data test;
format b best32.;
x = '0010000000130000123';
len1 = length(x);
b = input(x, best32.);
run;
output from test datasets:
x = 10000000130000123
b = 10000000130000124
Expected output:
x = 10000000130000123
b = 10000000130000123
My question is why value from column 'b' has been round?
I am expecting that column 'x' and column 'b' having the same value.
Senico
For starters, X i char and B in numeric, which in most situation isn't comparable.
And you need to understand how SAS stores numerical values, and displaying them.
Leading zeros doesn't really hold any information, nor influence any calculation. Therefore, they are not displayed by default.
Use Zn. format (haven't I already said that?).
Linus, Not only starters have problems to understand how SAS works wiht numbers,,, uh it is IEE that applies everywhere..
Many more have people are having problems understanding working with numbers ... floating-flops.
Some background of how using a slider would be convenient.
I also need to file a complaint to my laser surgery practice, I just saw the rounding "error"... :smileyblush:
I dont beleive that there is a solution to this problem in the SAS environment.
The default length of a numeric variable is 8 bytes, this is also the maximum length. The largest integer that can be expressed exactly in SAS is 9,007,199,254,740,992.
I notice that your example numbers have leading zeroes, and these supposed to be codes of some kind? You might want to consider storing them as character varaibles where they can be stored exactly.
Jaap Karman gave you the right reference material. Let me give you the short answer.
No, it's not possible. The way that SAS stores numeric values, it has room to store only 15 to 16 significant digits (ASCII vs. EBCDIC). If you want an accurate representation of longer values, you will have to print the character variable instead.
There are exceptions. If you experiment with numbers that are multiple of 8, for example, you will see that you can store more significant digits. However, understanding why requires reading up on the reference material that you'll find in Jaap's link.
Good luck.
The magic question here is how Senico wish to use these large numbers?
Is it just exploration of SAS limitations, or a real life problem?
Hi,
This is real life problem.
I need to transform the example from character column to numeric column
and use it as account_number:
0010000000130000123 -> 10000000130000123
Senico
It is common practice across most industries that use account numbers to store them as character columns - for example banking.
I am curious to know why you want to transform them into numeric columns.
As it is indeed making no sense to try calculating the mean or skewness on accountnumbers... A correlation with the GPS y location?
The best approach would be tot treat it as char. It are characters within the 0-9 range (constraint).
One exception, bankers are having problems with numbers. The IBAN number? (of course no number as it contains A-Z.
But the made a convention with mod 97 calculation wiht 2 checking chars on it. As the resolution in the number is a common problem this calculation has been split up in several parts in the example. International Bank Account Number - Wikipedia, the free encyclopedia
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.