Data visualization with SAS programming

Forest plot for clinical data

Reply
New Contributor Lop
New Contributor
Posts: 3

Forest plot for clinical data

Dear experts,

I need some help with this proc. I tried to draw a forest plot as the link below.

(https://blogs.sas.com/content/graphicallyspeaking/2012/02/01/forest-plot-using-sgplot-procedure/#pre...)

For that I used two different sintaxes, but any of them helped me to see the expected result.

 

data forestplot ;
input Covariates$ OddsRatio LCL UCL ;
datalines ;
assm_1st_tertile  1.55 0.78 3.08
assm_2nd_tertile 1.12 0.55 2.28
age                     1.09 1.04 1.14
glucose                 1.02 1.01 1.04
hdl_c                 0.90 0.87 0.92
tg                         1.01 1.00 1.01
homair                 1.95 1.50 2.52
msbp                 1.08 1.05 1.11
mdbp                 0.99 0.95 1.03
form_smok         1.13 0.32 3.94
curr_smok             0.67 0.11 4.14
form_drink             1.96 0.59 6.48
curr_drink             0.92 0.58 1.48
reg_exerc             0.73 0.36 1.49
separated             0.73 0.11 4.68
widow                 2.47 1.23 4.97
divorced             1.66 0.64 4.28
highsch                 1.15 0.66 2.00
college                 1.31 0.69 2.48
inc2                     0.92 0.56 1.52
inc3                     0.70 0.35 1.42
;
run;

*Method 1_Using inside;
data _null_;
  pct=0.75/nobs;
  height=4;
  dpi=120;
  call symputx("pct", pct);
  call symputx("pct2", 2*pct);
  call symputx("dpi", dpi);
  call symputx("height", height);
  call symputx("heightin", height || "in");
  call symputx("thickness", floor(height*dpi*pct));
  set forestplotx nobs=nobs;
run;

proc template;
   define style styles.ForestColor93;
      parent = Styles.htmlBlue;
      style GraphFonts  from GraphFonts /                                                                
         'GraphDataFont' = ("<sans-serif>, <MTsans-serif>",7pt)                                 
         'GraphValueFont' = ("<sans-serif>, <MTsans-serif>",7pt);
      style GraphData1 from GraphData1 /                                      
         contrastcolor = GraphColors('gcdata2')                               
         color = GraphColors('gdata2');
      style GraphData2 from GraphData2 /                                      
         contrastcolor = GraphColors('gcdata1')                               
         color = GraphColors('gdata1');
   end;
run;

ods html close;
ods graphics  / reset width=6in height=&heightin imagename="MetScov" ;
ods listing sge=off style=Styles.ForestColor93 image_dpi=&dpi;
title "Relative Risk of Metabolic Syndrome (OR and 95% CI)";
title2 h=9pt 'Odds Ratio and 95% CL';

proc sgplot data=forestplot noautolegend nocycleattrs;
  scatter y=covariates x=oddsratio / markerattrs=(symbol=diamondfilled size=5.5);
  highlow y=covariates low=lcl high=ucl / type=line;
  refline 1 100 / axis=x;
  refline 0.01 0.1 10 / axis=x lineattrs=(pattern=shortdash) transparency=0.5;
  xaxis type=log offsetmin=0 offsetmax=0.35 min=0.01 max=100 minor display=(nolabel) ;
  x2axis offsetmin=0.5 display=(noticks nolabel);
  yaxis display=(noticks nolabel) offsetmin=&pct offsetmax=&pct2 reverse;
  yaxistable oddsratio lcl ucl / location=inside position=right ;
 run ;

 *Method 2_Using markerchar;
proc sgplot data=forestplot noautolegend nocycleattrs;
  scatter y=covariates x=oddsratio / markerattrs=(symbol=diamondfilled size=5.5);
  highlow y=covariates low=lcl high=ucl / type=line;
  scatter y=covariates x=oddsratio / markerchar=oddsratio x2axis;
  scatter y=covariates x=lcl / markerchar=lcl x2axis;
  scatter y=covariates x=ucl / markerchar=ucl x2axis;
  refline 1 100 / axis=x;
  refline 0.01 0.1 10 / axis=x lineattrs=(pattern=shortdash) transparency=0.5;
  xaxis type=log offsetmin=0 offsetmax=0.35 min=0.01 max=100 minor display=(nolabel) ;
  x2axis offsetmin=0.3 display=(noticks nolabel);
  yaxis display=(noticks nolabel) offsetmin=&pct offsetmax=&pct2 reverse;

run ;

 

Could you gently explain me what is going on. Thanks in advance for all helpful insights.

I'm attaching the graphs that I got.

 

Forestplot_inside.pngForestplot_markerchar.png

 

Ask a Question
Discussion stats
  • 0 replies
  • 92 views
  • 0 likes
  • 1 in conversation