%let gpath='C:\'; %let dpi=200; ods html close; ods listing gpath=&gpath image_dpi=&dpi; data forest; input Id Subgroup $3-27 Count Percent Mean Low High PCIGroup Group PValue; zero=0; one=1; subgroup_lbl='Subgroup'; Count_lbl='Count and (%)'; PCI_lbl='PCI Group'; grp_lbl='Group'; pval_lbl='P Value'; ObsId=_n_; if count ne . then CountPct=put(count, 4.0) || "(" || put(percent, 3.0) || ")"; datalines; 1 Overall 2166 100 1.3 0.9 1.5 17.2 15.6 . 1 Age . . . . . . . 0.05 2 <= 65 Yr 1534 71 1.5 1.05 1.9 17.0 13.2 . 2 > 65 Yr 632 29 0.8 0.6 1.25 17.8 21.3 . 1 Sex . . . . . . . 0.13 2 Male 1690 78 1.5 1.05 1.9 16.8 13.5 . 2 Female 476 22 0.8 0.6 1.3 18.3 22.9 . 1 Race or ethnic group . . . . . . . 0.52 2 Nonwhite 428 20 1.05 0.6 1.8 18.8 17.8 . 2 White 1738 80 1.2 0.85 1.6 16.7 15.0 . 1 From MI to Randomization . . . . . . . 0.81 2 <= 7 days 963 44 1.2 0.8 1.5 18.9 18.6 . 2 > 7 days 1203 56 1.15 0.75 1.5 15.9 12.9 . 1 Infract-related artery . . . . . . . 0.38 2 LAD 781 36 1.4 0.9 1.9 20.1 16.2 . 2 Other 1385 64 1.1 0.8 1.4 15.6 15.3 . 1 Ejection Fraction . . . . . . . 0.48 2 < 50% 1151 54 1.2 0.8 1.5 22.6 20.4 . 2 >= 50% 999 46 0.9 0.6 1.4 10.7 11.1 . 1 Diabetes . . . . . . . 0.41 2 Yes 446 21 1.4 0.9 2.0 29.3 23.3 . 2 No 1720 79 1.1 0.8 1.5 14.4 13.5 . ; run; /*--Replace '.' in subgroup with blank--*/ data forest2; label subgroup='Subgroup'; label countpct='Count (%)'; label high='Odds Ratio'; set forest; subgroup=translate(subgroup, ' ', '.'); val=mod(_N_-1, 6); if val eq 1 or val eq 2 or val eq 3 then ref=obsid; /*--Set indentation--*/ indent=1; if id=1 then indent=0; run; /*proc print;run;*/ /*--SAS 9.3 Using MarkerCharacter--*/ proc template; define statgraph Forest_Markercharacter_93; dynamic _bandcolor; begingraph; layout lattice / columns=2 columnweights=(0.4 0.6); /*--First column for Subgroup and patient counts--*/ layout overlay / walldisplay=none x2axisopts=(display=(tickvalues) offsetmin=0.3 offsetmax=0.3 tickvalueattrs=(size=8)) yaxisopts=(reverse=true display=none tickvalueattrs=(weight=bold) offsetmin=0); referenceline y=ref / lineattrs=(thickness=14 color=_bandcolor); scatterplot y=obsid x=subgroup_lbl / markercharacter=subgroup xaxis=x2; scatterplot y=obsid x=count_lbl / markercharacter=countpct xaxis=x2; endlayout; /*--Second column showing odds ratio graph--*/ layout overlay / yaxisopts=(reverse=true display=none offsetmin=0) walldisplay=none xaxisopts=(tickvalueattrs=(size=8) labelattrs=(size=9)); referenceline y=ref / lineattrs=(thickness=14 color=_bandcolor); highlowplot y=obsid low=low high=high; scatterplot y=obsid x=mean / markerattrs=(symbol=squarefilled); referenceline x=1; endlayout; endlayout; endgraph; end; run; ods graphics / reset width=5in height=3.5in imagename='Forest_Markercharacter_93'; proc sgrender data=forest2 template=Forest_Markercharacter_93; dynamic _bandcolor='cxf0f0f0'; run; /*--SAS 9.3 Using Data Label--*/ proc template; define statgraph Forest_DataLabel_93; dynamic _bandcolor; begingraph; layout lattice / columns=2 columnweights=(0.4 0.6); /*--First column for Subgroup and patient counts--*/ layout overlay / walldisplay=none x2axisopts=(display=(tickvalues) offsetmin=0.15 offsetmax=0.3 tickvalueattrs=(size=8)) yaxisopts=(reverse=true display=none tickvalueattrs=(weight=bold) offsetmin=0); referenceline y=ref / lineattrs=(thickness=14 color=_bandcolor); scatterplot y=obsid x=subgroup_lbl / datalabel=subgroup markerattrs=(size=0) datalabelposition=right xaxis=x2 discreteoffset=-0.25; scatterplot y=obsid x=count_lbl / datalabel=countpct markerattrs=(size=0) datalabelposition=center xaxis=x2; endlayout; /*--Second column showing odds ratio graph--*/ layout overlay / yaxisopts=(reverse=true display=none offsetmin=0) walldisplay=none xaxisopts=(tickvalueattrs=(size=8) labelattrs=(size=9)); referenceline y=ref / lineattrs=(thickness=14 color=_bandcolor); highlowplot y=obsid low=low high=high; scatterplot y=obsid x=mean / markerattrs=(symbol=squarefilled); referenceline x=1; endlayout; endlayout; endgraph; end; run; ods graphics / reset width=5in height=3.5in imagename='Forest_DataLabel_93'; proc sgrender data=forest2 template=Forest_DataLabel_93; dynamic _bandcolor='cxf0f0f0'; run; /*--SAS 9.3 Using Data Label Indented--*/ proc template; define statgraph Forest_DataLabel_Indent_93; dynamic _bandcolor; begingraph; layout lattice / columns=2 columnweights=(0.4 0.6); /*--First column for Subgroup and patient counts--*/ layout overlay / walldisplay=none x2axisopts=(display=(tickvalues) offsetmin=0.15 offsetmax=0.3 tickvalueattrs=(size=8)) yaxisopts=(reverse=true display=none tickvalueattrs=(weight=bold) offsetmin=0); referenceline y=ref / lineattrs=(thickness=14 color=_bandcolor); scatterplot y=eval(ifn(id=1, obsid, .)) x=subgroup_lbl / datalabel=subgroup markerattrs=(size=0) datalabelposition=right xaxis=x2 discreteoffset=-0.25 datalabelattrs=(weight=bold size=8 color=blue); scatterplot y=eval(ifn(id=2, obsid, .)) x=subgroup_lbl / datalabel=subgroup markerattrs=(size=0) datalabelposition=right xaxis=x2 discreteoffset=-0.15 datalabelattrs=(weight=normal size=7); scatterplot y=obsid x=count_lbl / datalabel=countpct markerattrs=(size=0) datalabelposition=center xaxis=x2 datalabelattrs=(weight=normal size=7); endlayout; /*--Second column showing odds ratio graph--*/ layout overlay / yaxisopts=(reverse=true display=none offsetmin=0) walldisplay=none xaxisopts=(tickvalueattrs=(size=8) labelattrs=(size=9)); referenceline y=ref / lineattrs=(thickness=14 color=_bandcolor); highlowplot y=obsid low=low high=high; scatterplot y=obsid x=mean / markerattrs=(symbol=squarefilled); referenceline x=1; endlayout; endlayout; endgraph; end; run; ods graphics / reset width=5in height=3.5in imagename='Forest_DataLabel_Indent_93'; proc sgrender data=forest2 template=Forest_DataLabel_Indent_93; dynamic _bandcolor='cxf0f0f0'; run; /*--Template uses a Layout Lattice of 1 column--*/ proc template; define statgraph Forest_One_Column_94; dynamic _bandcolor _headercolor _subgroupcolor; begingraph; discreteattrmap name='text'; value '1' / textattrs=(weight=bold); value '2' / textattrs=(weight=normal); enddiscreteattrmap; discreteattrvar attrvar=textid var=id attrmap="text"; layout lattice / columns=2 columnweights=(preferred 0.5); /*--Column headers--*/ sidebar / align=top; layout lattice / rows=1 columns=2 columnweights=(0.4 0.6) backgroundcolor=_headercolor opaque=true; entry textattrs=(size=8 weight=bold) halign=left "Subgroup No. of Patients (%)"; entry textattrs=(size=8 weight=bold) "Hazard Ratio"; endlayout; endsidebar; /*--Columns on the left--*/ layout overlay / yaxisopts=(reverse=true display=none offsetmin=0) walldisplay=none; referenceline y=ref / lineattrs=(thickness=14 color=_bandcolor); innermargin / align=left opaque=false; axistable y=obsid value=subgroup / labelattrs=(size=7) indentweight=indent textgroup=textid; axistable y=obsid value=countpct / labelattrs=(size=7); endinnermargin; endlayout; /*--Graph in the middle--*/ layout overlay / yaxisopts=(reverse=true display=none offsetmin=0) walldisplay=none xaxisopts=(tickvalueattrs=(size=8) labelattrs=(size=9)); referenceline y=ref / lineattrs=(thickness=14 color=_bandcolor); highlowplot y=obsid low=low high=high; scatterplot y=obsid x=mean / markerattrs=(symbol=squarefilled); referenceline x=1; endlayout; endlayout; endgraph; end; run; /*--Render Forest Plot with horizontal bands--*/ ods graphics / reset width=5in height=3.5in imagename='Forest_OneCol_94'; proc sgrender data=Forest2 template=Forest_One_Column_94; dynamic _bandcolor='cxf0f0f0' _headercolor='cxd0d0d0'; run;