Date: Fri, 4 Sep 2009 19:21:08 -0400
Reply-To: "Kirby, Ted" <ted.kirby@LEWIN.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Kirby, Ted" <ted.kirby@LEWIN.COM>
Subject: Geometric mean of observatons by category
In-Reply-To: A<20090904162141.EDT93062@ms3.nss.udel.edu>
Content-Type: text/plain; charset="us-ascii"
I would like to get the geometric mean of values by category. What
would be ideal would be if PROC MEANS had a Geometric Mean option
analogous the MEAN SUM or other statistical calculation. However, I
could find no indication of this capability of PROC MEANS in the
documentation.
I can calculate the geometric mean by sorting the dataset and then
process the data in a SAS data step using the "FIRST.var" and "LAST.var"
operations. However, I was wondering if it was possible to get it using
the GEOMEAN function.
For example:
data have
input category number;
datalines;
100 2
110 3
120 4
110 8
100 9
100 1
120 6
120 3
100 5
110 9
120 3
;
run;
For this dataset I would an output that looks like this.
Category Geometric Mean of Number
100 2.08
110 6.00
120 2.83
I feel like I am missing some really obvious or simple methodology, but
I just can't think of anything at the moment.
My real data set has 13 million observations and 500+ categories. Thus,
I would like the code to be as efficient as possible (i.e., not take
hours to run, if possible).
I have SAS 9.1.3 on Windows XP professional.
Thanks.
************* IMPORTANT - PLEASE READ ********************
This e-mail, including attachments, may include confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately.