DATA Step, Macro, Functions and more

SQL table Numeric out of range

Reply
Super Contributor
Posts: 271

SQL table Numeric out of range

[ Edited ]

 

I am doing some calculation like 

 

data output;

set input;

A= (col1* col2*col3)/(100000*col4);

run;

 

My value in A is always less than 10,000 but when I am loading this output datasset in the  MS SQL table it is giving an error Numeric out of range.

One option is to increase the length of column in SQL table but I am looking for solution -  what should I do in data step so that data can be inserted into MS SQL table without getting an error. 

 

The place holder in MS SQL have sufficient length.

Seondly, I also tried using round function in data step but it didnt help.

Valued Guide
Posts: 596

Re: SQL table Numeric out of range

You don't say what the number in col4 is but my guess is that once you multiply that by 100,000 you're exceeding the largest number that SQL Server can hold. A similar thing happened on one system I worked on with ORACLE. 

Super User
Posts: 5,914

Re: SQL table Numeric out of range

What is your columns definition i SQL Server, and what values are rejected?

Data never sleeps
Super Contributor
Posts: 271

Re: SQL table Numeric out of range

Existing definition - decimal(24,10)

 

When I changed to decimal(27,10) then it works.

 

I do not want to change the existing definition.

Super User
Posts: 5,914

Re: SQL table Numeric out of range

Ok, not following. Either it fits, or not. Can't see that this is a SAS problem.

It seems that you either need to fix your data, or your columns definitions.

Data never sleeps
Ask a Question
Discussion stats
  • 4 replies
  • 110 views
  • 0 likes
  • 3 in conversation