```Date: Fri, 21 Jan 2005 17:25:52 -0800 Reply-To: Dale McLerran Sender: "SAS(r) Discussion" Comments: DomainKeys? See http://antispam.yahoo.com/domainkeys From: Dale McLerran Subject: Re: geomean questions. In-Reply-To: Content-Type: text/plain; charset=us-ascii --- "David L. Cassell" wrote: > Dale McLerran replied [in small part]: > > To do this, you must first compute a variable > > LOG_X = log(x) in a data step. From there, the simple way to > > get the geometric mean of X would be to run PROC NLMIXED with > > code > > > > proc nlmixed data=mydata; > > model log_x ~ normal(mu, var); > > estimate "Geometric mean of X" exp(mu); > > run; > > Okay, can we have a show of hands? Does anyone else think this > is the SIMPLE way to get the geometric mean? :-) :-) > OK, I'll admit that the suggestion to use NLMIXED is non-intuitive. I had not thought of it until I had started my post. Still, I will have to argue that it is THE SIMPLE WAY to get the statistic, at least for a single response. We can construct a data step in which we cumulate sums and frequencies, as David shows below. So, if we assess simplicity in terms of how many data steps/procedures one must code in order to get the statistic, there are "simpler" approaches. > options nocenter nodate nonumber ps=60 ls=75 noovp; > > data temp1; > do y = 1 to 3; > do x = 3*y to 20*y by 3; output; end; > end; > y = 3; x = .; output; > run; > > data temp2(keep = y count logsum geo_mean); > do until(last.y); > set temp1; > by y; > count = sum(count, not missing(x) ); > logsum = sum(logsum, log(x) ); > end; > geo_mean = exp( logsum / count ); > run; > > proc print data=temp2; run; > OK, let's see those hands raised for the DoW approach versus data temp2; set temp1; log_x = log(x); run; proc nlmixed data=temp2; by y; model log_x ~ normal(mu, var); estimate "Geometric mean" exp(mu); run; Which one is simpler? Vote now. And in the spirit of recent vote tabulations, vote often! Dale ===== --------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center mailto: dmclerra@NO_SPAMfhcrc.org Ph: (206) 667-2926 Fax: (206) 667-5977 --------------------------------------- __________________________________ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo ```

Back to: Top of message | Previous page | Main SAS-L page