BookmarkSubscribeRSS Feed
india2016
Pyrite | Level 9

Hello All,

I am trying to create a numeric variable which has value "657253982556657625876"  after creating this variable the output I got is wrong i.e. "657253982556657680384".

My program is :

data abc;
format id best32.;
input id;
datalines;
657253982556657625876
;


run;

2 REPLIES 2
jklaverstijn
Rhodochrosite | Level 12

Your number exceeds what SAS can store numerically in 8 bytes. Have a look at the on-line documentation to see what the limits are for your operating system. If you are running Windows your maximum integer value is 9,007,199,254,740,992. You can see your number exceeds this. The article I refer to contains some pointers on how to deal with t his. Basically it comes down to the choice between magnitude and precision.

 

Hope this helps,

-- Jan

jklaverstijn
Rhodochrosite | Level 12

Looking at your code I see the variable is named ID. This suggests that the number is used for identification and no arithmetic will be performed on it. I suggest you store the variable as a character variable to avoid numerical errors of the sort you are experiencing.

 

Hope this helps,

-- Jan

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
  • 2 replies
  • 649 views
  • 2 likes
  • 2 in conversation