Forest Plotting Analysis Macro %FORESTPLOT (Paper 3419) Jeffrey Meyers Qian Shi, PhD. Mayo Clinic, Rochester MN The forest plot is a graph commonly associated with meta analysis. It allows for a quick visual comparison of estimates across subgroups or variable levels. They are not as commonly used as other graphics because of the amount of work to produce one. The estimate and any other statistics to be displayed must be calculated, added to a final plot dataset, and then plotted. If a forest plot is comparing multiple model outputs, then the code to produce the statistics becomes replicated and prone to errors. The forest plot macro fully automates multiple types of analyses including Cox proportional hazards regression, logistic regression, Kaplan-Meier event-free rates, and binomial success rates, and gives a vast amount of customization options. The macro also includes the flexibility of being able to input a pre-generated dataset to transform into a high quality forest plot. Copyright © 2010, SAS Institute Inc. All rights reserved.
Forest Plot Example (Graphically Speaking) The forest plot is a graph commonly associated with meta analysis. It allows for a quick visual comparison of estimates across subgroups or variable levels. They are not as commonly used as other graphics because of the amount of work to produce one. The estimate and any other statistics to be displayed must be calculated, added to a final plot dataset, and then plotted. If a forest plot is comparing multiple model outputs, then the code to produce the statistics becomes replicated and prone to errors. Lets look at this graph from Sanjay’s Graphically Speaking blog and assume that each of these models is a single comparison. This would mean up to 9 models would have to be run, combined, and output to make this one graph. I believe this is one of the main contributors to why forest plots are not used as often as other graphics. #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.
Forest Plot Example (%FORESTPLOT) The code to actually produce a forest plot from a dataset is not complicated, especially in SAS 9.4. This is an example of my macro using nearly the same dataset as the previous slide to generate a custom forest plot. The macro has some differences, namely some of the formatting. The FORESTPLOT macro can use pre-generated data to output a forest plot, but that is not its main purpose. #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.
Purpose Creation of high quality forest plots with high level of customizations Automate the calculations of ratios and estimates involved with forest plot Logistic and Cox proportional hazards regression, Kaplan-Meier time-point estimates, binomial success rate, user provided data Analysis across factors of a variable, subgroups, or in Univariate and multivariate models Automate the creation of a dataset most conducive to producing a forest plot #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.
Plot Setup Graph is designed with Graph Template Language (GTL) Two separate versions for SAS 9.2 and 9.3+ Due to limitations within 9.2 alleviated in 9.3+ Nearly every piece of graph is customizable Can be output in many formats (PNG, JPEG, TIFF, EMF, PDF, PS, etc.) Size, location, and name of file customizable Can be included within ODS tags in larger report
Macro Process METHOD Determines Analysis Method Cox Regression Method Kaplan-Meier Estimate Method Transform Dataset into Final Plot Dataset Create Template And Generate Plot Error Checking Logistic Regression Method Analysis + Output Dataset Inputs Binomial Success Rate Method Inputted Data Method This slide will have the “consort diagram” of the macro process flow #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.
Sample Datasets (Logistic/Binomial) Neuralgia dataset provided by SAS Link to dataset creation Treatment: A and B are active arms P stands for Placebo arm Insert table of first several rows of dataset #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.
Sample Datasets (Kaplan-Meier) BMT dataset provided by SAS Located in SASHELP library (version 9.3 or later) Version 9.2 creation T: time from transplant to death Status: 0=Alive, 1=Dead Group=Disease Category ALL=Acute Lymphoblastic Leukemia AML=Acute Myeloid Leukemia Insert first few rows of dataset #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.
Estimates Across Levels of a Factor Statistics In order requested X-axis options Labels, range, type Automatic label Automatic levels Reference line
Customized Title Automatic footnotes Categorical factors Level vs reference Multiple formats Continuous factors Adjustable step size Markers Symbols, colors, size Line thickness Changeable by model Plot walls
Disabled automatic footnotes Spaces between models Headers Super or Subscripts Line breaks Manual footnotes Categorical format 2 levels condensed Continuous format Condensed to one row Disabled automatic footnotes Spaces between models
Column header for model titles Specific factors listed from each model 2 level factors can be combined into one row Model level statistics Concordance N Events/Total P-values Factor level statistics Ratios/Rates
Example of Subgroup Analysis Model Titles Where clauses Separate by model Line-caps disabled Separate p-values by model Multiple time-points Text overflows into plot Add examples of different kinds of forest plots with different formatting #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.
Example of Subgroup Analysis Use of multiple BY variables Pooled value for comparison Multiple formats available Default label Manual label Add examples of different kinds of forest plots with different formatting #SASGF13 Copyright © 2013, SAS Institute Inc. All rights reserved.
Plot Example (SAS 9.2) Scalable vector graphics unavailable Pooled value for comparison More tabular display Reference on own row
Closing Forest plots are a versatile method for displaying data %FORESTPLOT greatly reduces effort required to build a forest plot Goals for the future: More types of analyses such as linear regression Allow more panels of plots and statistics
References First Example Concordance Methods: “Graphically Speaking: Forest Plot with SAS 9.3.” Sanjay Matange, January 6, 2013 Concordance Methods: Cox Regression: Therneau T (2014). _A Package for Survival Analysis in S_. R package version 2.37-7, <URL: http://CRAN.R-project.org/package=survival>. Logistic Regression: cNeil BJ: The meaning and use of the area under a receiver operating characteristic (ROC) curve. Radiology 143:29-36, 1982.
Contact Information Name: Jeffrey Meyers Enterprise: Mayo Clinic Address: 200 1st St SW City, State ZIP: Rochester, MN 55905 Work Phone: 507-266-2711 E-mail: Meyers.Jeffrey@mayo.edu jpmeyers.spa@gmail.com Twitter: jmeyers_spa SAS Community Wiki Page: Link The forest plot macro greatly alleviates the amount of effort required to produce a high quality forest plot, and gives a vast amount of customizability to meet the users needs. Forest plots are very useful beyond meta-analysis and are more informative than a basic table.