BookmarkSubscribeRSS Feed
kwu
SAS Employee kwu
SAS Employee
when I define a numeric variable (or attrib) in a dataset, since the variable would only have value in the range of 1-9000K, so I would like to define the length of variable to be 4 (bytes). based on rule in other database ststem, a 4 bytes integer should be able to handle max value of 2147483647. However, when try to insert a value greater than 2500k, it starts having the round off error, SAS does not complian the overflow (no warning or error) but just insert it with round off error.
I am trying to understand how sas stores the numeric value with different length and how to calculate the safe data range for a specified length? Also is there a way to add a check constrain to let SAS to spit an error when overflow happens?

I am new to SAS, any suggestion would be high appreciated.
3 REPLIES 3
Dale
Pyrite | Level 9
I don't know where you are getting your value of 2147483647 as the maximum integer value that could be stored precisely in 4 bytes. SAS documentation for both Windows and Unix environments indicates that the largest integer value which can be precisely stored in 4 bytes is 2097152, far smaller than 9000K=9000000. A 5 byte variable can precisely represent integer values through 536870912, so increasing your variable length by 1 byte would solve your problem here.

I would note that this question is much more about Base SAS than it is about SAS Statistical Procedures. In fact, I would say that there is really nothing in this post that has to do with Statistical Procedures. You would be likely to get a much better, more knowledgeable response if you posted your problem in the proper forum. Might I suggest the SAS Macro Facility, Data Step and SAS Language Elements forum.
kwu
SAS Employee kwu
SAS Employee
Dale:
thank you. that value is from other programming language like fortran or c for a 4 bytes integer.

could you please send me the doc where you find the precisely stored value for 4 bytes? I could not find it in SAS help.

I did mean to post it in data step and sas langugae element forum but I was browsing each one and did not realize that I posted on the wrong forum. Thank you for the suggestion though.
Dale
Pyrite | Level 9
Here is a link that gives the byte specification and maximum integer values on a Windows OS:

http://support.sas.com/onlinedoc/913/getDoc/en/hostwin.hlp/numvar.htm

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1165 views
  • 0 likes
  • 2 in conversation