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. 🙂
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.
Once you get parameter of lognormal distribution, you can use QUANTITLE() function to get CI .
Or try Bootstrap method.
Or Calling @Rick_SAS
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;
Thanks all! This got me what I needed! To output the last table I used ods output parameterestimates=parest
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.