Not applicable
Posts: 0

# Proc Tabulate or Proc Report - Geometric means

Is there a way to have the geometric mean as a summary statistic using Proc tabulate or Proc report?
SAS Super FREQ
Posts: 9,365

## Re: Proc Tabulate or Proc Report - Geometric means

Hi:
It depends on what version of SAS you're running. According to this site:

Geometric means
To compute the geometric mean of values in a variable, use Base SAS Sample Library program GEOMEAN. Beginning in SAS 9.1, you can compute the geometric mean of values in an observation using the Base SAS function GEOMEAN or GEOMEANZ.

Here's the site for the sample program for SAS 8:
http://support.sas.com/kb/25/366.html

Check the documentation for the GEOMEAN function explanation. The documentation path is:
Functions and CALL Routines --> GEOMEAN Function (under the category Descriptive Statistics)

Since you can only compute variables in a COMPUTE block or use functions in PROC REPORT, you would not be able to use the GEOMEAN with PROC TABULATE.

According to the doc, an example of invoking the GEOMEAN function would be some thing like:

gmn=geomean(1,2,2,4); OR
gmn=geomean(v1, v2, v3, v4); OR
gmn=geomean(of x1-x4);

Which in PROC REPORT world would be something like this:
[pre]
data mydata;
infile datalines;
input x1 x2 x3 x4;
return;
datalines;
1 2 2 4
. 2 4 8
2 2 2 2
;
run;

ods listing;
proc report data=mydata nowd;
column x1 x2 x3 x4 gmn;
define x1 / display;
define x2 / display;
define x3 /display;
define x4 / display;
define gmn / computed;
compute gmn;
gmn = geomean(of x1-x4);
endcomp;
run;

[/pre]

For more help with the GEOMEAN function, consider contacting Tech Support.

Note that the variables passed to the GEOMEAN function must be on the same row.

cynthia
Occasional Contributor
Posts: 7