Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- ODS and Base Reporting
- /
- Fast/Easy way to display Geometric Mean in a boxpl...

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-29-2018 11:38 AM

I have inherited a general boxplot program (V9.4) that displays the mean. I need to update to reporting the geometric mean.

The current program is using a boxplot statement in PROC TEMPLATE, which is then called in PROC SGRENDER:

proc template;

define statgraph XXX;

begingraph ;

...blah blah axis options and titles and whatnot...

boxplot y=yvar x=xvar / datalabelattrs=(color=black size=4) boxwidth=0.25 display=(caps fill median mean outliers);

endlayout;

endgraph;

end;

run;

proc sgrender data=mydata template = XXX;

run;

quit;

I'm not finding any options to display geometric means. I'm poking around at using PROC SGPLOT instead with VBOX, but I'm not finding any options there either.

Unless there is some awesomely cool proc or option I'm missing, I'm thinking my best bet may be to suppress printing the mean, calculate geo-mean, and overlay it separately. Any suggestions?

Many many thanks,

VCM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-29-2018 11:54 AM

Isn't there a transformation you can do that will give you the geo mean? Take the log and then the average is your geo mean?

Could you add the transformed data to your graph, but make it invisible and have that mean calculated as your shown statistic?

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

03-29-2018 12:03 PM

I think the geo mean is the exp of the mean of the log, so I don't think just creating new variable = log(yvar) and then running it through the sgrender will work. (Someone correct me if I'm wrong?)

VCM

VCM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-29-2018 12:08 PM

You're probably correct, I didn't look at it much, the other suggestion is create it as a macro variable and include that value in your SGRENDER procedure as a dynamic variable.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-29-2018 12:59 PM - edited 03-29-2018 04:25 PM

Fast/easy way? I guess that depends on how you define "fast" and "easy", but I would say NO there isn't a fast/easy way to do this.

You could always compute the geometric mean before your run your boxplots, and then annotate them onto the plot. You can do the calculations using the GEOMEAN or GEOMEANZ functions in a data step, or the GEOMEAN option in PROC UNIVARIATE.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-04-2018 04:19 AM - edited 04-04-2018 04:20 AM

I was able to get this by suppressing the mean in the box, and adding a scatterplot statement to plot the geometric mean (which had been calculated earlier in the program):

boxplot x=xvar y=yvar /whiskerattrs=(thickness=0) display=(fill median outliers);

scatterplot x=xvar y=gmean/MARKERATTRS=(SIZE=6pt color=cx0066ff SYMBOL=trianglefilled);

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-04-2018 10:46 AM

What about a TEXT statement? Instead of scatterplot?