## What is the maximum order numeric variable that SAS is able to process?

Solved
Occasional Learner
Posts: 1

# What is the maximum order numeric variable that SAS is able to process?

Hi everyone,

This is my first post with SAS Support communities, so please bear with me and pardon my misgivings.

I ran into an issue lately where I was trying to convert a character variable into a numeric variable while extracting data from a dataset. The character variable was a 18 digit long numeric value stored as character. So, when I tried importing the variable and converting it into numeric using the input function, only the first 16 digits were getting converted successfully and the last 2 digits were getting arbitrarily random values. So, I took the empirical approach and devised the following simple code to check is SAS is able to process the numericals upto 10^18 numerical precision, and I found that last 2 digits were always lost. Can you please help me understand if my conclusion is correct? Is SAS unable to handle numerical variables beyond 10^16 value? Please adivse.

Code:

214  data _null_ ;

215     do i=1 to 17 ;

216        big_num = 10**i + 1 ;

217        put big_num best18. +2 i 2. ;

218     end ;

219  run ;

Result:

11   1

101   2

1001   3

10001   4

100001   5

1000001   6

10000001   7

100000001   8

1000000001   9

10000000001  10

100000000001  11

1000000000001  12

10000000000001  13

100000000000001  14

1000000000000001  15

10000000000000000  16

100000000000000000  17

For observation 16 and 17 it can be seen that the numerical precision is lost. Please advise how can I go around this issue? Thanks in advance.

Accepted Solutions
Solution
‎02-19-2014 11:38 AM
Super User
Posts: 8,115

## Re: What is the maximum order numeric variable that SAS is able to process?

Posted in reply to vkumbhakarna

16   data _null_;

17     max=constant('exactint');

18     put max=comma21.;

19   run;

max=9,007,199,254,740,992

Easiest way to deal with it is to NOT convert your character variable into an numeric.

All Replies
Solution
‎02-19-2014 11:38 AM
Super User
Posts: 8,115

## Re: What is the maximum order numeric variable that SAS is able to process?

Posted in reply to vkumbhakarna

16   data _null_;

17     max=constant('exactint');

18     put max=comma21.;

19   run;

max=9,007,199,254,740,992

Easiest way to deal with it is to NOT convert your character variable into an numeric.

Super User
Posts: 23,752

## Re: What is the maximum order numeric variable that SAS is able to process?

Posted in reply to vkumbhakarna

I don't believe this is a SAS specific issue, as I've seen it in Excel and R recently as well.

Trusted Advisor
Posts: 3,215

## Re: What is the maximum order numeric variable that SAS is able to process?

Posted in reply to vkumbhakarna

This is indeed no SAS specific issue. It is related to what processor you are using.

SAS(R) 9.2 Language Reference: Concepts, Second Edition  (precision) The floating point area are processor instrcutions.

Do not forget SAS(R) 9.4 DS2 Language Reference, Second Edition as there the approach is differtent and the limitations are different.

http://blogs.sas.com/content/sastraining/2013/04/08/jedi-sas-tricks-finding-tattoine-with-ds2/

Floating point - Wikipedia, the free encyclopedia

---->-- ja karman --<-----
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
• 3 replies
• 315 views
• 7 likes
• 4 in conversation