- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 10-07-2022 03:23 AM
(782 views)
Hi,
I have Account_ID of length $36. I am trying to convert this to numeric variable but it truncates the last digits or converts the last digit to 0000. Kindly help with the issue.
I have Account_ID of length $36. I am trying to convert this to numeric variable but it truncates the last digits or converts the last digit to 0000. Kindly help with the issue.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
ID variables should not be numeric. Precision of storage is extremely likely to result in modified, i.e. rounded to fit the precision values.
Are you doing arithmetic with Id variables? Why? If you are not doing arithmetic then the variable should stay character.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Satyakshma wrote:
Hi,
I have Account_ID of length $36. I am trying to convert this to numeric variable but it truncates the last digits or converts the last digit to 0000. Kindly help with the issue.
You cannot convert a digit string with 36 characters into a number exactly. The maximum integer that can be represented as a number in SAS before you start losing precision is:
23 data _null_; 24 max = constant('exactint'); 25 put max= comma24.; 26 run; max=9,007,199,254,740,992
So the maximum length digit string you can be sure will exactly be represented by a number is 15 digits.
You should not store ID values as numbers anyway. You do not want to take the mean of the ID number.