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
SAS Super FREQ
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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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