In teradata proc sql in SAS Enterprise guide environment, I am trying to create a column by multiplying two fields, but I have been having overflow issue. How do I specify the number of decimals in the resulting field during Select statment? numeric(20,2)
proc sql exec feedback stimer; connect to teradata as teravw (authdomain=teradataauth TDPID=DWPROD2 MODE=TERADATA SCHEMA=EDW_NOPHI CONNECTION=GLOBAL); CREATE TABLE WORK.tbl1 AS SELECT * from connection to teravw (SELECT ... ,case when PCL.CLM_SOR_CD = '512' then cast(round(sum(PCL.PRCG_WHLSL_ALWBL_COST_AMT * CL.PAID_SRVC_UNIT_CNT) ,0.01) as numeric(20,2)) else SUM(PCL.PRCG_WHLSL_ALWBL_COST_AMT) end AS WAC ... ); disconnect from teravw; quit; run;
error message:
ERROR: Teradata row not delivered (trget): Numeric overflow occurred during computation.
Advertisement
Answer
SAS stores all numbers as 8 byte floating point numbers. The maximum number of significant decimal digits is less than 20. Are your values really larger than 9,999,999,999,999.99? Did you try DECIMAL(15,2)?
You can cast the value as FLOAT and attach a format on the SAS side to only display 2 decimal places.
create table my_dataset as select wac format=20.2 from connection to teradata ( select cast( .... as FLOAT) as wac from ... );
If you really need to store 20 decimal digits exactly then you will need to split the value into two fields.