The advent of the AXISTABLE statement with SAS 9.4, has made it considerably easier to create graphs that include statistics aligned with x-axis values (Survival Plot) or with the y-axis (Forest Plot). This statement was specifically designed to address such needs, and includes the options needed to control the text attributes of the data and also any indentations that may be needed.
In previous posts, I have described the use of these new statements, but it seems I did not provide a full program for the "Subgrouped Forest Plot", one of many popular clinical graphs. Here we can use the YAXISTABLE available in SGPLOT for this graph
- A Hazard Ratio plot in the middle.
- Study names on the far left. The study names are subgrouped, with label and values. The labels have bolder font and the values are indented.
- Number of patients with % on the left.
- Event rates for PCI Group, Therapy Group and p-value on the right.
- Note the use of Unicode arrow characters for the annotations on the axis created using the TEXT plot statement. This is done using the ability to add Unicode values to a User Defined Format in SAS 9.4M3.
- SG Annotation code is NOT used in this graph.
SAS 9.40M3 code:
title j=r h=7pt '4-Yr Cumulative Event Rate';
ods graphics / reset width=5in height=3in imagename='Subgroup_Forest_SG_94';
proc sgplot data=forest_subgroup_2 nowall noborder nocycleattrs dattrmap=attrmap noautolegend;
format text $txt.;
refline ref / lineattrs=(thickness=13 color=cxf0f0f7);
highlow y=obsid low=low high=high;
scatter y=obsid x=mean / markerattrs=(symbol=squarefilled);
scatter y=obsid x=mean / markerattrs=(size=0) x2axis;
refline 1 / axis=x;
text x=xl y=obsid text=text / position=bottom contributeoffsets=none strip;
yaxistable subgroup / location=inside position=left textgroup=id labelattrs=(size=7)
yaxistable countpct / location=inside position=left labelattrs=(size=7) valueattrs=(size=7);
yaxistable PCIGroup group pvalue / location=inside position=right pad=(right=15px)
yaxis reverse display=none colorbands=odd colorbandsattrs=(transparency=1) offsetmin=0.0;
xaxis display=(nolabel) values=(0.0 0.5 1.0 1.5 2.0 2.5);
x2axis label='Hazard Ratio' display=(noline noticks novalues) labelattrs=(size=8);
I have also added this code to the CTSPedia page for Subgrouped Forest Plot.
Full SAS 9.40M3 code: Subgrouped_Forest_Plot_SG_94