BookmarkSubscribeRSS Feed
Ujjawal
Quartz | Level 8

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.

8 REPLIES 8
ballardw
Super User

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.

Ujjawal
Quartz | Level 8

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;

ballardw
Super User

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

Ujjawal
Quartz | Level 8

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

ballardw
Super User

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.

Ujjawal
Quartz | Level 8

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;

Rick_SAS
SAS Super FREQ

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.

Ksharp
Super User

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

new_var=log(var);

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 23926 views
  • 0 likes
  • 4 in conversation