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


I have a character variable with values of numbers (17-18 digits). I wanted to convert them into numeric. But the last two digits have changed for some reason.

The sas code I used is:

data convert;

set original;

numeric=input(character 18.0);

format numeric 18.0;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
snoopy369
Barite | Level 11

Depending on your operating system, SAS can only handle around 15 digits of precision with a numeric (in Windows, out of 64 bits for an 8 byte number, 1 is the sign and 11 are the exponent, meaning 52 bits are available for the mantissa (the precise digits) - around 4x10^15. Any number over 4x10^15 will begin losing precision.  See SAS(R) 9.2 Language Reference: Concepts, Second Edition for more information.

View solution in original post

3 REPLIES 3
snoopy369
Barite | Level 11

Even 16 digits is not safe.  2^53 (around 4x10^15) is the maximum storable number with full precision; so some Visa numbers may be storable, but no Mastercard numbers (5x10^15).  This of course is often relevant with credit card numbers simply because they are right at that point of precision loss.

snoopy369
Barite | Level 11

Depending on your operating system, SAS can only handle around 15 digits of precision with a numeric (in Windows, out of 64 bits for an 8 byte number, 1 is the sign and 11 are the exponent, meaning 52 bits are available for the mantissa (the precise digits) - around 4x10^15. Any number over 4x10^15 will begin losing precision.  See SAS(R) 9.2 Language Reference: Concepts, Second Edition for more information.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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