Help using Base SAS procedures

numeric resizing erroneous results

Reply
N/A
Posts: 0

numeric resizing erroneous results

Hi,

I execute the following in SAS 9.1:
proc sql;
create table work.test1(x int);
quit;

data work.test11;
length x 4;
set work.test1;
run;

proc sql;
insert into work.test11
values (20081101)
;
quit;
/* !! 20081101 --> 20081088 in work.test11 */

I have the unpleasant surprise to see that inserting the integer value 20081101 into a 4-byte numeric column changes the value to 20081088.

Is this a serious bug in SAS or am I doing something wrong?

Thanks in advance for help,
Chris
N/A
Posts: 0

Re: numeric resizing erroneous results

Posted in reply to deleted_user
length 4 is too small, please read http://support.sas.com/techsup/technote/ts654.pdf
N/A
Posts: 0

Re: numeric resizing erroneous results

Posted in reply to deleted_user
Thanks a lot for pointing that resource, urchin.
Until now , I thought that 4 bytes for numeric type in SAS can hold 32 bits of integer values, thus the limit (for signed integers) of around 2 billion for positive values.
Now I realize that SAS stores in a different way the numeric values and I also wonder if there is a way to have 4 bytes numeric size and still be able to hold 32 bits signed integers (in other words, is there a way to change the way SAS stores integers?).

Chris
Ask a Question
Discussion stats
  • 2 replies
  • 96 views
  • 0 likes
  • 1 in conversation