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

I'm trying to convert a set of character strings into numbers, and it's not as expected.

 

Anyone have any ideas on how to trouble shoot?

 

data want;
set have;
num=input(char,best32.);
run;

 

Obs num char
1323242600026000064512323242600026000122499
2313244000040000684032313244000040000698990
3313242000020000145408313242000020000198990
4314245000050000134144314245000050000159970
5323242600026000261120323242600026000222499
6323242600026000261120323242600026000222499
7313244000040000290816313244000040000298990
8323242600026000064512323242600026000122499
9423242250022500433920423242250022500512797
10323245000050000134144323245000050000171980

 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Assuming you are on a PC, the maximum precision that can be stored by SAS integers is 16 digits (2**53) since SAS stores numbers in 64 bits (8 bytes), and some of these are not used for the mantissa (the digits of the number). Your numbers are longer than this.

 

If you store real numbers, full precison is not always possible, and SAS has further issues (see https://communities.sas.com/t5/Base-SAS-Programming/Expected-numeric-precision-behaviour-or-unexpect...).

 

View solution in original post

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

Assuming you are on a PC, the maximum precision that can be stored by SAS integers is 16 digits (2**53) since SAS stores numbers in 64 bits (8 bytes), and some of these are not used for the mantissa (the digits of the number). Your numbers are longer than this.

 

If you store real numbers, full precison is not always possible, and SAS has further issues (see https://communities.sas.com/t5/Base-SAS-Programming/Expected-numeric-precision-behaviour-or-unexpect...).

 

JS
Obsidian | Level 7 JS
Obsidian | Level 7

Thanks Chris! This was exceptionally informative and helpful.

SASKiwi
PROC Star

What do these numbers represent? Leave them as character if you are not doing mathematics on them.

JS
Obsidian | Level 7 JS
Obsidian | Level 7

Thanks SASKiwi. This was a unique problem that we ran into, and in the future we're going to restructure our coding algorithms to use character strings instead.

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
  • 4 replies
  • 1034 views
  • 3 likes
  • 3 in conversation