DATA Step, Macro, Functions and more

ERROR: Floating Point Overflow

Reply
Regular Contributor
Posts: 183

ERROR: Floating Point Overflow

Hi Experts,

The following error is coming when i run proc logistic on some variables.

These variables are transformed variables - For example, sqrt root, cube root, square,

exp value etc.

ERROR: Floating Point Overflow.

ERROR: Termination due to Floating Point Exception

What i found on google is that it is because of too large value. This is the code i am using prior to that.

data output;

set output;

array transvars{*} &numvar;

array srtvar{*} &srtvar;

array sqvar{*} &sqvar;

array logvar{*} &logvar;

array invvar{*} &invvar;

array cbvar{*} &cbvar;

array cbrtvar{*} &cbrtvar;

array expvar{*} &expvar;

do mi = 1 to dim(transvars);

if not missing(transvars{mi}) then do;

transvars{mi} = round(transvars{mi},.01);

srtvar{mi} = round(sqrt(transvars{mi}),.01);

logvar{mi} = round(log(max(.0001,transvars{mi})),.01);

invvar{mi} = round(1/max(.0001,transvars{mi}),.01);

sqvar{mi} = round(transvars{mi}**2,.01);

cbvar{mi} = round(transvars{mi}**3,.01);

cbrtvar{mi} = round(transvars{mi}**.3333,.01);

expvar{mi} = round(exp(max(.0001,transvars{mi})),.01);

end;

end;

drop mi;

run;

I am rounding off to two digits, still error not resolving.

Super User
Posts: 11,343

Re: ERROR: Floating Point Overflow

You can also get this overflow from dividing by small numbers.

You should show the logistic code as well. Too many parameters could be an issue.

Regular Contributor
Posts: 183

Re: ERROR: Floating Point Overflow

Thanks for your response. Yes, some values are as small as .00005 and some as big as 99999999.456789. Rounding off is not working to correct them. The PROC LOGISTIC code is shown below. There are 8 independent variables- Original Variable, Square root of it, square, cube, cube root, log, inverse, exp.

ODS OUTPUT EFFECTNOTINMODEL = Estimate&i.;

PROC LOGISTIC DATA = &output. DESC;

MODEL &depvar. = &varName. &srtvar1. &sqvar1. &logvar1. &invvar1. &cbvar1. &cbrtvar1. &expvar1.

/ SELECTION = S MAXSTEP = 1 DETAILS;

RUN;

There are some warnings while executing array code - " Invalid argument to function operation : EXP, SQRT and *** " . I thought it is because of missing values. I put condition in array - IF NOT MISSING THEN DO. But these warnings are still coming.

Detailed Code :

%macro test(input = ,depvar=, output=);

data _null_;

call symput ("library", put(upcase(substr("&input",1,index("&input",'.')-1)), $8.));

call symput ("datset", put(upcase(substr("&input",index("&input",'.')+1,length("&input"))), $32.));

run;

*Selecting numeric variables;

proc sql noprint;

select name into : numvar separated by " "

from dictionary.columns

where LIBNAME = "&library"

and MEMNAME = "PREDATA"

and type = 'num';

quit;

%let varn=%sysfunc(countw(&numvar%str( )));

   

*Run for all the numeric variables;

%DO i=1 %TO &varn;

*Selecting Variable one by one;

%let varName =%scan(%sysfunc(compbl(&numvar)),&i,%str( ));

%let srtvar1 = sqrt_&varName.;

%let sqvar1  = sq_&varName.;

%let logvar1 = log_&varName.;

%let invvar1 = inv_&varName.;

%let cbvar1  = cb_&varName.;

%let cbrtvar1= cbrt_&varName.;

%put &varName. &srtvar1.;

options  symbolgen;

ODS OUTPUT EFFECTNOTINMODEL = Estimate&i.;

PROC LOGISTIC DATA = &output. DESC;

MODEL &depvar. = &varName. &srtvar1. &sqvar1. &logvar1. &invvar1. &cbvar1. &cbrtvar1.

/ SELECTION = S MAXSTEP = 1 DETAILS;

RUN;

options  nosymbolgen;

%end;

%mend;

Super User
Posts: 11,343

Re: ERROR: Floating Point Overflow

If you are taking the square or cube of 99999999.456789 those are at least a few of your culprits.

Regular Contributor
Posts: 183

Re: ERROR: Floating Point Overflow

Oops. Correct! Exp is the biggest culprit then. I need to cap some variables. Thanks for your time.

Super User
Posts: 11,343

Re: ERROR: Floating Point Overflow

You may want to look into the Constant function for replacements of extreme values.

Constant('BIG') is the largest double-precision value,

Constant('LOGBIG') is the log of the largest number

Constant('SQRTBIG') is the square root of the biggest and similar for 'SMALL' values.

Regular Contributor
Posts: 183

Re: ERROR: Floating Point Overflow

Thanks a ton Ballardw. I tried using the CONSTANT function. Is it used with PROC IML only,

Is it correct to use like this ?

Lsqr = CONSTANT('SQRTBIG');

srtvar{mi} = sqrt(min(Lsqr, transvars{mi}));

sqvar{mi} = min(CONSTANT('LOGBIG',10) ,transvars{mi})**2;

SAS Super FREQ
Posts: 3,753

Re: ERROR: Floating Point Overflow

The CONSTANT function is part of Base SAS and can be called from the DATA step or procedures (like PROC SQL).  Like most other Base SAS functions, it can also be called from SAS/IML software, but it is not part of SAS/IML.

Super User
Posts: 10,035

Re: ERROR: Floating Point Overflow

If the variable's value is way too big . Try to log it. and use new variables to build model .

new_var=log(var);

Ask a Question
Discussion stats
  • 8 replies
  • 6655 views
  • 0 likes
  • 4 in conversation