SUPPORT / SAMPLES & SAS NOTES
 

Support

Sample 43855: Forest plot macro

DetailsCodeResultsDownloadsAboutRate It

This sample creates several forest plots using the Graph Template Language (GTL). This sample is supported beginning with the third maintenance release of SAS 9.2 (TS2M3).

A forest plot is a graphical display of the relative strength of treatment effects in multiple quantitative scientific studies addressing the same question (Wikipedia). This sample creates several forest plots.

The sample requires a macro that can be downloaded from the Downloads tab. After downloading the macro, the sample code on the Full Code tab can be submitted from your SAS session.

Three types of observations (1-Study, 2-Subgroup, and 3-Overall) are supported using the optional GROUP variable. These are rendered using the GraphData1, GraphData2, and GraphData3 style elements, respectively.

Two macro variables, MYPATH and MACROLOC, are created at the beginning of the sample code. MYPATH contains the path to the directory in which the graphs and the HTML file are stored. This macro variable is currently set to C:\TEMP. The macro variable MACROLOC contains the path to the directory in which the SAS program ForestMacro.sas is stored. This program needs to be downloaded from the Downloads tab. In the sample code, the SAS program ForestMacro.sas is expected to be stored in the C:\TEMP folder.

The macro parameters are described below.

Macro Parameter Description with default value
Data= Data set name (required)
Study= Variable name for study (required)
OddsRatio= Variable name for odds ratio (required)
LCL= Variable name for lower confidence limit (required)
UCL= Variable name for upper confidence limit (required)
Group= Variable name for study type
Weight= Variable name for study weight in %
StatCol1= Variable name for an additional stat column to be displayed
StatCol2= Variable name for an additional stat column to be displayed
StatCol3= Variable name for an additional stat column to be displayed
StatCol4= Variable name for an additional stat column to be displayed
DisplayCols=YES Display the columns for OR, LCL, UCL, and Weight
WfFactor= Multiplier factor for study weights
Bands=YES Draw horizontal alternating bands
Borders=NO Draw borders
GraphWalls=NO Draw filled walls behind the graph
StatWalls=NO Draw filled walls behind the statistics tables
Width=640px Width of the graph
Height= Height of the graph, which is estimated if not provided
LabelColWidth= Fractional width for label column (default=0.2)
Label1= Favorable label (default="Favors Treatment")
Label2= Unfavorable label (default="Favors Control")
PlotTitle= Plot title (default="Odds Ratio and 95% CL")
FootNote= Graph footnote
Title2= Graph subtitle
Title= Graph title (default="Impact of Treatment on Mortality by Study”)



These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.