LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 1996, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 23 Apr 1996 21:16:02 +0100
Reply-To:     Jose Luis Alabart <joseluis@MIZAR.CSIC.ES>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Jose Luis Alabart <joseluis@MIZAR.CSIC.ES>
Subject:      Re: Geometric Row Mean

What about this code?

DATA D1; INPUT X1 X2 X3 X4; gmean=exp(mean(log(x1),log(x2),log(x3),log(x4))); CARDS; 1 1 1 1 2 2 2 2 1 2 1 2 3 4 5 6 1 10 100 1000 ; PROC PRINT; RUN;

The SAS System 1 20:46 Tuesday, April 23, 1996

OBS X1 X2 X3 X4 GMEAN

1 1 1 1 1 1.0000 2 2 2 2 2 2.0000 3 1 2 1 2 1.4142 4 3 4 5 6 4.3559 5 1 10 100 1000 31.6228

Perhaps it is a little tedious, but it works... nad there is nothing that can't be solved by "copy-paste" and "replace"... :-)

>I posted a question last week about computing the row geometric mean of a >series of 30 or 40 adjacent variables. Several kind souls came up with >what seemed to be fairly easy solutions to the problem, except when I >tried them they didn't work correctly. > >One solution was: > >gmean = exp(mean(log(x1 -- x40))); > >This solution takes advantage of the fact that the arithmetic mean of >logarithms is equal to the logarithm of the geometric mean, which can in >turn be reconstituted to its original form via the exp function. >This solution is imminently logical and causes no problem, except that it >gives the wrong answer. When tested with a small number of variables, it >appears to take the logarithm of the sum of x1+x2+x3+x4 (in a four >variable case), instead of summing the logs of x1, x2, x3, x4. I'm using >SAS 6.11. > >Any other ideas, or comments on what is actually wrong with the code above. > >Thank you very much for your time. > > *********************************************************************** > * Dr. Marc R. Feldesman | email: feldesmanm@pdx.edu| Beyond every * > * Professor and Chairman | fax: (503)-725-3905 | credibility * > * Anthropology Department | voice: (503)-725-3081 | gap lies a * > * Portland State University | pager: (503)-870-2515 | gullibility * > * Portland, Oregon 97207 | home: NOT | fill * > *********************************************************************** J.L. Alabart Servicio de Investigacion Agraria Apdo. 727 50080 Zaragoza (Spain) FAX: (Spain) 76 57 55 01 Voice: (Spain) 76 57 63 36 (Spain) 76 57 63 11 Tx. 58194 IDAE E E-mails: JOSELUIS@mizar.csic.es (or) ALABART@cc.unizar.es


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