BookmarkSubscribeRSS Feed
VCM
Obsidian | Level 7 VCM
Obsidian | Level 7

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 

6 REPLIES 6
Reeza
Super User

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?

 

 

VCM
Obsidian | Level 7 VCM
Obsidian | Level 7
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
Reeza
Super User

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. 

PaigeMiller
Diamond | Level 26

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
VCM
Obsidian | Level 7 VCM
Obsidian | Level 7

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);

Reeza
Super User

What about a TEXT statement? Instead of scatterplot?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 2862 views
  • 5 likes
  • 3 in conversation