The SAS Output Delivery System and reporting techniques

Proc Tabulate or Proc Report - Geometric means

Reply
N/A
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: 8,868

Re: Proc Tabulate or Proc Report - Geometric means

Posted in reply to deleted_user
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
Occasional Contributor
Posts: 7

Re: Proc Tabulate or Proc Report - Geometric means

Posted in reply to Cynthia_sas

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
Ask a Question
Discussion stats
  • 2 replies
  • 2460 views
  • 0 likes
  • 3 in conversation