Hi,
I need to calculate Geom. mean and Geom. CV and I'm using PROC TTEST for it.
However, often we have cases where the following error occurs:
ERROR: Computations would cause floating point overflow.
I assume that this is caused by the confidence interval calculation leading to too small numbers, but I cannot bypass this even if not calling the CI in the procedure.
Here is an example code to test the issue:
data check;
AVAL=10.4;
output;
AVAL=1.3; *Works on AVAL=5;
output;
run;
proc ttest data=check dist=lognormal ci=NONE cl=NONE;
var aval;
ods output ConfLimits=_COUNT_STAT_GEOMM_00(rename=(GeomMean=GEOMM CV=GCV));
run;
Hello @roskaasia and welcome to the SAS Support Communities!
It's indeed the upper confidence limit for the geometric coefficient of variation which is causing the issue: According to the formulas in the documentation, SAS would try to compute
sqrt(exp(s**2/cinv(0.025,1))-1)
for your sample dataset, where (using your initial test data)
s=log(10.4/1.3)/sqrt(2)
But then exp(s**2/cinv(0.025,1))=exp(2201.5136...)=1.274...E956, which exceeds constant('big')=1.797...E308 by orders of magnitude, hence the overflow error.
With 3.1934 instead of 1.3 the exp(...) term is slightly below constant('big'): 1.786...E308.
I'd suggest that you compute mean and standard deviation of the log-transformed data and then transform back to the original scale, as described in the documentation linked above:
data logcheck;
set check;
if aval>0 then log_aval=log(aval);
run;
proc summary data=logcheck;
var log_aval;
output out=logstats(drop=_:) n=n mean=m std=s;
run;
data want(drop=m s);
set logstats;
geomm=exp(m);
gcv=sqrt(exp(s**2)-1);
run;
proc print data=want;
run;
You could also compute the other statistics (confidence intervals), if needed.
Thanks for the input! Rounding doesn't solve the issue unfortunately.
For the second dummy value in the example code, using anything less than 3.1934 will lead into the floating point overflow error.
So for example, this works just fine, creating the below output:
data check;
AVAL=10.4;
output;
AVAL=3.1934; *Works on AVAL=5 or if AVAL>=3.1934;
output;
run;
proc ttest data=check dist=lognormal;
var aval;
ods output ConfLimits=_COUNT_STAT_GEOMM_00(rename=(GeomMean=GEOMM CV=GCV));
run;
Probably the issue is that the confidence interval for the CV becomes too large when the second dummy value is less than 3.1934. But I still need to calculate the Geometric mean with the original example values, so is there any way to disable the confidence limits from this procedure, as I don't even need them?
Hello @roskaasia and welcome to the SAS Support Communities!
It's indeed the upper confidence limit for the geometric coefficient of variation which is causing the issue: According to the formulas in the documentation, SAS would try to compute
sqrt(exp(s**2/cinv(0.025,1))-1)
for your sample dataset, where (using your initial test data)
s=log(10.4/1.3)/sqrt(2)
But then exp(s**2/cinv(0.025,1))=exp(2201.5136...)=1.274...E956, which exceeds constant('big')=1.797...E308 by orders of magnitude, hence the overflow error.
With 3.1934 instead of 1.3 the exp(...) term is slightly below constant('big'): 1.786...E308.
I'd suggest that you compute mean and standard deviation of the log-transformed data and then transform back to the original scale, as described in the documentation linked above:
data logcheck;
set check;
if aval>0 then log_aval=log(aval);
run;
proc summary data=logcheck;
var log_aval;
output out=logstats(drop=_:) n=n mean=m std=s;
run;
data want(drop=m s);
set logstats;
geomm=exp(m);
gcv=sqrt(exp(s**2)-1);
run;
proc print data=want;
run;
You could also compute the other statistics (confidence intervals), if needed.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.