Sample 25366: Computing geometric means
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample is from the SAS Sample Library. For additional information refer to SAS Help and Online Documentation.
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: GEOMEAN */
/* TITLE: Computing Geometric Means */
/* PRODUCT: SAS */
/* SYSTEM: ALL */
/* KEYS: DATASTEP ARRAY MEANS DO FUNCTIONS LOG EXP PRINT */
/* PROCS: MEANS PRINT */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: */
/* */
/****************************************************************/
OPTIONS LS=72;
TITLE 'GEOMETRIC MEANS';
DATA;
INPUT X Y Z@@;
CARDS;
2 3 1 2 5 6 4 3 2 1 2 3 45 68 6 5 4 3 2 2 1
2 3 2 2 1 3 -46 7 765 4 33 2 2 32 3 5 5 3 2 25 4 32 23
4 3 2 32 32 23 4 4 -55 2 23 1 1 22 32 32
;
RUN;
DATA LOGS;
SET;
ARRAY L (3) X Y Z;
DO I=1 TO 3;
IF L(I)>0 THEN L(I)=LOG(L(I));
ELSE L(I)=.;
END;
RUN;
PROC MEANS;
VAR X Y Z;
OUTPUT OUT=MEANLOGS MEAN=X1 Y1 Z1;
RUN;
DATA GEOMEAN;
SET MEANLOGS;
ARRAY MLOG(3) X1 Y1 Z1;
DO I=1 TO 3;
MLOG(I)=EXP(MLOG(I));
END;
RUN;
PROC PRINT;
RUN;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
GEOMETRIC MEANS
The MEANS Procedure
Variable N Mean Std Dev Minimum Maximum
--------------------------------------------------------------------
X 19 1.5943722 1.1812635 0 3.8066625
Y 19 1.8980900 1.3244552 0 4.2195077
Z 20 1.4789700 1.5305031 0 6.6398758
--------------------------------------------------------------------
GEOMETRIC MEANS
Obs _TYPE_ _FREQ_ X1 Y1 Z1 I
1 0 20 4.92524 6.67314 4.38842 4
This example demonstrates how to compute geometric means.
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> MEANS Analytics ==> Descriptive Statistics
|
| Date Modified: | 2005-10-29 03:02:56 |
| Date Created: | 2005-05-23 13:48:53 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |