Thinking about it again, to take advantage of LAYOUT LATTICE you can also use the annotate facility to create the N entries outside. See below for an example, it uses the same data for plotting additionally also an annotate dataset is create to draw the N values (in red).
/*
* make SGanno macro available
*/
%sganno
data anno_a;
set group_a_stat end=eod;
%SGTEXT(
id="GROUP_A"
, label=cats(value_a_n)
, xc1=group_a
, x1space="datavalue"
, y1=-7.5
, y1space="wallpercent"
, textcolor="red"
)
if eod = 1 then do;
%SGTEXT(
id="GROUP_A"
, label="label"
, x1=0
, x1space="wallpercent"
, y1=-7.5
, y1space="wallpercent"
, anchor="right"
, border="true"
, widthunit="percent"
, width=150
)
end;
run;
data anno_b;
set group_b_stat end=eod;
%SGTEXT(
id="GROUP_B"
, label=cats(value_b_n)
, xc1=group_b
, x1space="datavalue"
, y1=-7.5
, y1space="wallpercent"
, textcolor="red"
)
if eod = 1 then do;
%SGTEXT(
id="GROUP_B"
, label="label"
, x1=0
, x1space="wallpercent"
, y1=-7.5
, y1space="wallpercent"
, anchor="right"
, border="true"
, textcolor=""
, widthunit="percent"
, width=150
)
end;
run;
data anno;
set anno_a anno_b;
run;
/*
* create your own GTL
*/
proc template;
define statgraph two_vbox;
dynamic _ticklist_;
begingraph / ;
layout lattice / columns=2 rowdatarange=union columndatarange=unionall ;
column2headers;
entry "Group A colum2headers";
entry "Group B colum2headers";
endcolumn2headers;
layout overlay /
pad=(bottom=5pct)
xaxisopts=(type=Discrete discreteOpts=(sortOrder=ascendingFormatted)
display=(line ticks tickvalues))
;
entry "Group A layout" / valign=top;
BoxPlot X=group_a Y=value_a / primary=true LegendLabel="value_a" NAME="VBOXa";
annotate / id="GROUP_A";
endlayout;
layout overlay /
xaxisopts=(type=Discrete discreteOpts=(sortOrder=ascendingFormatted) display=(line ticks tickvalues))
;
entry "Group A layout" / valign=top;
BoxPlot X=group_b Y=value_b / primary=true LegendLabel="value_b" NAME="VBOXb";
annotate / id="GROUP_B";
endlayout;
endlayout;
endgraph;
end;
run;
proc sgrender data=group_combined template=two_vbox sganno=anno;
run;
... View more