BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
joon1
Quartz | Level 8

Dear Madam/Sir,

I construct "r1" variable using financial data and calculate "pbp" with exponential function.

 

r1=-1.32-0.407 *size + 6.03*TLTA - 1.43*WCTA + 0.0757*CLCA - 2.37*NITA - 1.83*FUTL + 0.285*INTWO - 1.72*OENEG - 0.521*CHIN;
pbp=1/(1+exp(-r1));

 

However, I have the following error message and many "pbp" value generates missing values.

 

NOTE: Invalid argument to function EXP(1077.0290778) at line 226 column 10.
NOTE: Invalid argument to function EXP(730.03261995) at line 226 column 10.
NOTE: Invalid argument to function EXP(2948.7729907) at line 226 column 10.
NOTE: Invalid argument to function EXP(1961.5518226) at line 226 column 10.
NOTE: Invalid argument to function EXP(755.8640734) at line 226 column 10.
NOTE: Invalid argument to function EXP(1152.1594476) at line 226 column 10.
NOTE: Invalid argument to function EXP(950.27392335) at line 226 column 10.
NOTE: Invalid argument to function EXP(2908.9920974) at line 226 column 10.
NOTE: Invalid argument to function EXP(947.47746471) at line 226 column 10.

It will be highly appreciative if you can advise me how to resolve this issue.

 

Thanks

Joon1

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @joon1,

 

It looks like you're working with a logistic regression model and you want to apply the logistic function (i.e., the inverse of the logit function) to r1. You don't need to type in the formula for the logistic function because SAS has already implemented it in the LOGISTIC function.

 

Example:

data test;
do r1=-5, -10, -50, -100, -500, -1000;
  pbp=logistic(r1);
  output;
end;
run;

proc print data=test;
format pbp best21.;
run;

Result:

Obs       r1                      pbp

 1        -5         0.00669285092428
 2       -10          0.0000453978687
 3       -50      1.9287498479639E-22
 4      -100      3.7200759760208E-44
 5      -500     7.1245764067411E-218
 6     -1000                        0

The result pbp=0 for r1=-1000 is, of course, rounded down from 5.076E-435, but the unavoidable rounding errors of the other results are much greater than this and you don't get missing values or pesky notes in the log.

 

View solution in original post

7 REPLIES 7
ChrisNZ
Tourmaline | Level 20

EXP(755.8640734) is 1.851809 × 10^328

That's a number larger than 10^308 that IEEE 754 computers can store.

What do you want to do with a 328-digit number?

mkeintz
PROC Star

Take a look at documentation for the CONSTANT function (not the EXP function) at Constant Function 

 

In there it says this about the constant "LOGBIG":

You can exponentiate any floating-point number less than or equal to CONSTANT('LOGBIG') by using the exponential function, EXP, without causing any overflows.
So let's see what this value is on my windows machine:
data _null_;
 lb=constant('logbig');
 put lb=;
run;
which generates:
lb=709.78271289
Your arguments are too big to be exponentiated on a windows machine using double-precision floating point arithmetic, because they would exponentiate to a value larger than constant('big') [ =1.797693E308 on my machine].
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
joon1
Quartz | Level 8

Thank you so much for your help, mkeintz.

SASKiwi
PROC Star

Trying to calculate a power of e, which is about 2.718, with a large number like 1,000 will result in such an impossibly large number that SAS cannot handle. Even e to the power of 100 will result in a number with 43 zeroes on the end of it! You need to consider limiting the range of values being supplied to the EXP function to something reasonable. PBP will be very close to 0 for large values coming from EXP.  

joon1
Quartz | Level 8

Thank you so much for your help, SASkiwi.

FreelanceReinh
Jade | Level 19

Hello @joon1,

 

It looks like you're working with a logistic regression model and you want to apply the logistic function (i.e., the inverse of the logit function) to r1. You don't need to type in the formula for the logistic function because SAS has already implemented it in the LOGISTIC function.

 

Example:

data test;
do r1=-5, -10, -50, -100, -500, -1000;
  pbp=logistic(r1);
  output;
end;
run;

proc print data=test;
format pbp best21.;
run;

Result:

Obs       r1                      pbp

 1        -5         0.00669285092428
 2       -10          0.0000453978687
 3       -50      1.9287498479639E-22
 4      -100      3.7200759760208E-44
 5      -500     7.1245764067411E-218
 6     -1000                        0

The result pbp=0 for r1=-1000 is, of course, rounded down from 5.076E-435, but the unavoidable rounding errors of the other results are much greater than this and you don't get missing values or pesky notes in the log.

 

joon1
Quartz | Level 8

Thank you so much for your help, FreelanceReinhard.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 7 replies
  • 2040 views
  • 2 likes
  • 5 in conversation