BookmarkSubscribeRSS Feed
kec02171
Calcite | Level 5

I have a lognormal distribution and need to calculate an arithmetic mean and standard deviation. I can get these using the code below. The problem is that I need to also calculate confidence intervals using mean and stdev and I need to output these values to a dataset so I can do the calculation:

 

proc univariate data=have;

var x;

histogram x/dist=lognormal;

run;

 

How do I output this?: Bonus points if you can figure out how I can get confidence intervals for the mean and stdev below. 🙂

kec02171_0-1623615218140.png

 

4 REPLIES 4
PaigeMiller
Diamond | Level 26

To output the values to a SAS data set, you can use ODS OUTPUT.

 

proc univariate data=have;
    ods output moments=moments;
    var x;
    histogram x/dist=lognormal;
run;

I don't know of a way to compute the confidence intervals.

--
Paige Miller
Ksharp
Super User

Once you get parameter of lognormal distribution, you can use QUANTITLE() function to get CI .

Or try Bootstrap method.

Or Calling @Rick_SAS 

Rick_SAS
SAS Super FREQ

By definition, if X ~ Lognormal(mu, sigma), then Y=log(X) is distributed as N(mu, sigma).  So, compute Y, find the confidence interval for the mean, and then apply the EXP transform to map it back to the lognormal scale:

 

data have;
call streaminit(123);
do i = 1 to 1000;
   x = rand("Lognormal", 0.5, 1.3);
   output;
end;
run;

data Normal;
set Have;
logX = log(x);    /* logX ~ N(mu, sigma) */
run;

proc means data= Normal LCLM Mean UCLM;
var logX;
output out=MeansOut LCLM=lower UCLM=upper;
run;

data Want;
set MeansOut;
LCLM_LN = exp(lower);  /* transform the CI */
UCLM_LN = exp(upper);
run;

proc print data=Want; run;
kec02171
Calcite | Level 5

Thanks all! This got me what I needed! To output the last table I used ods output parameterestimates=parest

 

 

 

 

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is ANOVA?

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.

Discussion stats
  • 4 replies
  • 1421 views
  • 5 likes
  • 4 in conversation