BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Is there a way to have the geometric mean as a summary statistic using Proc tabulate or Proc report?
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
It depends on what version of SAS you're running. According to this site:
http://support.sas.com/kb/30/333.html (Frequently Asked For Statistics)

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
bmozdemir
Calcite | Level 5

Hello,

How would you add descriptive statistics on the bottom of the table and to get an output like that? Is it possible with proc report?

Thank you.

-x1x2x3
-157
-289
-3104
-435
N444
mean2.56.56.25
std.1.293.112.22
min134
median2.56.56
max4109
%CV51.647.835.5
geo. mean2.25.96.0

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 4566 views
  • 0 likes
  • 3 in conversation