Presentation is loading. Please wait.

Presentation is loading. Please wait.

SAS ® is a very powerful tool when producing Graphics. A single graphical data step can easily create a Kaplan Meier Plot, but there is no single graphical.

Similar presentations


Presentation on theme: "SAS ® is a very powerful tool when producing Graphics. A single graphical data step can easily create a Kaplan Meier Plot, but there is no single graphical."— Presentation transcript:

1 SAS ® is a very powerful tool when producing Graphics. A single graphical data step can easily create a Kaplan Meier Plot, but there is no single graphical function for the creation of a Forest Plot. This becomes more difficult when trying to create several Forest Plots due to the necessary use of the Annotate Dataset. A Forest Plot can be as simple or as detailed as you like. The Figure below shows an example of a Forest Plot created using a detailed Annotation (Figure 1). As the Annotation process is essentially the creation of the dataset it is quite easy to create a macro for the creation of the Forest Plot.. The Macro can also be extended to control the whole of the code and therefore used on almost any data using a similar format. If we take the example given in Figure 1 a macro can be created to control the following:  The size, colour and style of the fonts  The positioning of the Treatment Labels and Counts  The axis ranges and numbering  How the Confidence Intervals are shown  The indicator variable to use to create the Plot (including specific values for this variable)  The Figure Titles, numbering and / or Footnotes  Where to store the output (if required) The Macro can be written to control the Annotate Dataset and therefore the Figure, the data or a combination of both to create a Forest Plot as detailed as required. The Steps before creating the Annotate Dataset are controlled through the Macro Call. Data manipulation can be performed as part of the macro or outside. A very simple example of the creation of the Confidence Intervals and Hazard Ratios is given in this Poster. Here you can control the input data, the significance of the Confidence Intervals and any subgroup on which you want the Figure to show. For ease of explanation the creation of the Hazard Ratios and Confidence Intervals is shown in a Macro and the Annotate dataset for the Labels and Confidence Intervals are shown in another two separate Macros. It is entirely possible for the creation of these to be carried out in a single macro. The Annotate dataset uses the options ‘move’, draw’, ‘text’ and ‘label’ only for the creation of Figure 1. It is created directly from the dataset that stores the Hazard Ratios and Confidence Intervals to allow correct drawing of the lines and tips. The y and x variables tell SAS ® where to position the lines and the ‘move’ and ‘draw’ options tell SAS ® when to create the lines. Firstly the creation of the Confidence Intervals : %macro hazard(byvar=, meas=, cens=, censval=, sign=, var1=); proc phreg data=data1 outest=pdata2; by &byvar. ; model &meas.*&cens.(&censval.) = &var1 / alpha=&sign. rl; ODS OUTPUT PARAMETERESTIMATES = ESTS; run; ods listing; ****** ANY MANIPULATION REQUIRED *******; ****** For Manipulation of the estimates dataset ******; %mend; Once the dataset with the estimates for the Confidence Intervals and Hazard Ratios is created the annotation dataset for the drawing of the Confidence Intervals can be created: %macro confid (order =, sty=, col=, tips=, haz=, low=, upp=) data bars; set est; if &haz ne.; length function $8. text $40.; xsys = '2'; ysys = '2'; color=&col; y=id; x=&haz.; function='move'; output; if lcl gt 0 then do; x=lcl; function='draw'; output; link tips; end; if ucl ne. then do; x=ucl; function='draw'; output; link tips; end; return; *--- Tips of Confidence intervals; y=id-&tips.; function = 'move'; output; y=id+&tips.; function= 'draw'; output; y=id; function='move'; output; return; run; %mend; The information created in the macro above will be added to the estimates dataset and stored as the dataset BARS. The Hazard Ratio and Confidence Interval variables are included in the Macro call for ease where you have multiple results calculated on different groups in a dataset. Define any subgroup here. This is the variable that has the measurements that you wish to analyse The variable that denotes a censored observation What value of the censored variable is for censored results The significance level you want to perform the test at The Treatment groups The value of ID has been previously set to ensure that the groups are displayed in the correct order. Define the order of the XAXSIS. This allows you to control each output separately Define the colour to be used in the Figure Define the style to be used for the Figure The size of the tips at the end of the confidence intervals, for no tips use tips=0 Define the variable that contains the Hazard Ratios, and the upper and lower confidence Intervals The next step is for the creation of the labels and text for inclusion on the Forest Plot. The labels and text to include on the Forest Plot use the function ‘LABEL’ to place the text on the figure at the given position. The macro to create the Labels and text for Figure 1 is given below. %macro label (haz=, col=, mn_order=, sty=, var2=, group1=, group2=, group3=, xpos=); data labels; set ests; if &haz =. then do; length function $8. text $50.; xsys = '2'; ysys = '2'; color=&col; *--- Labels for the subgroups; y=id; x=&mn_order.; style=“&sty"; function = 'label'; text=&var2; size=0.8; position='0'; output; *--- Number of event; position='0'; function='label'; if variable=&group1. then text = 'T1:'||trim(left(eg1))||'/'||trim(left(ng1))||‘ ('||trim(left(put(pg1,4.1)))||'%)'||'T3:'||trim(left(em1))||'/‘||trim(left(nm1)) ||' (' || trim(left(put(pm1,4.1))) || '%)'; if variable=&group2. then text = 'T2:'||trim(left(eg2))||'/'||trim(left(ng2))||‘ ('||trim(left(put(pg2,4.1)))||'%)'||'T3:'||trim(left(em2))||'/'||trim(left(nm2)) ||' ('|| trim(left(put(pm2,4.1))) || '%)'; if variable=&group3. then text = 'T1+T2:'||trim(left(eg3))||'/'||trim(left(ng3))|| ('||trim(left(put(pg3,4.1)))||'%)'||'T3:'||trim(left(em3))||'/'||trim(left(nm3)) ||' ('|| trim(left(put(pm3,4.1))) || '%)'; *--- CAN ADD ADDITIONAL TEXT IF MORE THAN 3 COMPARASIONS REQUIRED; y=id+0.1; x=&xpos.; size=0.8; output; run; %mend; The macro shown here has been created for a Forest Plot showing three comparisons only – however to add additional comparisons would simply need additions of the same text used for Number of Events. The final step here is to set the Confidence interval annotation with the Labels annotation to create the final Annotate Dataset. data anno; set bars labels; run; The Annotate dataset is then referenced directly in the graphical procedure as below. In order to have control over the axis and the Hazard Ratio that you will plot this must be part of the macro too: %macro plot (haz=, order=); proc gplot data=ests; bubble id*&haz=event / vaxis=axis1 haxis=axis2 anno=anno href=1; axis1 offset=(2,5) minor=none major=none value=none label=none style=0; axis2 ORDER=(&order.); run; quit; %mend; The use of the macros can ease the creation of Forest Plots using the SAS ® system. This is compounded when the need to create several plots using similar data arises. The four macros detailed here, along with any further data manipulation required, can be transformed into a single macro to allow a simpler process in order to create a detailed output. Tells SAS ® where to position the subgroup labels in relation to the XAXIS The variable that gives the subgroup labels The treatments used to calculate the counts to be shown. Up to 3 treatments can be given Tells SAS ® where to position the counts in relation to the XAXIS The variable containing the Hazard Ratio to be plotted The scale you want the XAXIS to be shown as i.e. -1 to 6 by 1 For the Macro to be as robust as possible it is recommended that the Macro be written for the data manipulation AND the creation of the Annotate Dataset. The Forest Plot can be created using a single Macro Call The Macro has been split into four parts for ease of explanation


Download ppt "SAS ® is a very powerful tool when producing Graphics. A single graphical data step can easily create a Kaplan Meier Plot, but there is no single graphical."

Similar presentations


Ads by Google