- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
The following code:
ods graphics off;
proc sort data=Simon4 out=Simon4;
by Geschlecht;
run;
proc boxplot data=Simon4;
plot (IL10A IL10B IL10C IL10D)*Geschlecht/
HEIGHT=2 boxstyle=SCHEMATICID cboxfill=BIG cboxes=black;
insetgroup mean /
header = 'Mittelwerte jeweils zur Gruppe darunter';
run;
Gives me the following image:
How can I achieve that the numbers giving the means (e.g. 33.7385) are above the bars and not justified to the right?
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you have SAS 9.4M5 or later, you should use sgplot VBOX statement with DISPLAYSTATS=(MEAN).
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @romangelzhaeuse,
If all else fails, you can use the annotate feature to mask the existing inset values (with white rectangles) and write the same values where you want:
/* Create test data for demonstration */
data have;
do i=1 to 100;
e=rannor(1971);
do s=-1, 1;
IL10A=33.7385 +20*s*e; Geschlecht='m'; output;
IL10A=36.83532+20*s*e; Geschlecht='w'; output;
end;
end;
run;
proc sort data=have;
by Geschlecht;
run;
/* Compute mean values */
proc summary data=have;
by Geschlecht;
var il10a;
output out=means mean=mean;
run;
proc transpose data=means out=mw_means(drop=_:) prefix=mean_;
id Geschlecht;
var mean;
run;
/* Create Annotate dataset */
%annomac;
data anno;
length function color $8 style text $20;
set mw_means;
/* Mask the original INSETGROUP values with white
rectangles and write them at the desired position. */
when='A'; xsys='1'; ysys='5';
%bar(30,95.7,49.5,97.3,white,0,s) /* Coordinates (30, */
%label(30,96,put(mean_m,best8.),black,0,0,1,,B) /* 95.7, 49.5, etc.) */
%bar(80,95.7,99.5,97.3,white,0,s) /* will likely need */
%label(69.5,96,put(mean_w,best8.),black,0,0,1,,B) /* to be adapted. */
run;
/* Produce box plot with "centered" inset values */
proc boxplot data=have anno=anno;
plot IL10A*Geschlecht/
HEIGHT=2 boxstyle=SCHEMATICID cboxfill=BIG cboxes=black;
insetgroup mean /
header = 'Mittelwerte jeweils zur Gruppe darunter';
run;
Result (depending on output device, HSIZE and VSIZE graphics options):