Help using Base SAS procedures

Forest Plot using SGPLOT

Reply
Contributor
Posts: 43

Forest Plot using SGPLOT

Hi Everyone,

Is there any way to control the spacing on y-axis between each subgroup of a forest plot.

For example:

Age <=65

Age >75

Male

Female

White

Non White

etc..

Thanks for your help

Super User
Posts: 11,343

Re: Forest Plot using SGPLOT

Posted in reply to sasjourney

You might want to state which version of SAS you are using as the SG procedures have gone through lots of improvements in the last few releases. My first likely solution is for an older versiona but I believe there have been options added that might do what you need.

Also posting your code and an example of the data might make responses quicker.

SAS Super FREQ
Posts: 8,866

Re: Forest Plot using SGPLOT

Posted in reply to sasjourney

Hi:

  I believe there is a GTL example of a FOREST plot, as well as an SG Procedure example of a FOREST plot. You should be able to search in support.sas.com to find the example links. See screen shots.

cynthia


search_forest_plots.png
Contributor
Posts: 43

Re: Forest Plot using SGPLOT

Posted in reply to Cynthia_sas

Thanks Ballard and Cynthia,

I'm using SAS 9.3 on windows. Yes, there is an example from Sanjay's blog using GTL but I was trying to output similar output using SGPLOT. But the problem is, I couldn't group them together with a space in between each group. 

Below is the code i'm using

proc sgplot data=forest&i noautolegend;

  scatter y = subgroup x = orval / xerrorupper = upper_limit

                                   xerrorlower = lower_limit

          markerattrs = graphdata1 (symbol = squarefilled);

  scatter y = subgroup x = trt1_lbl   / markerchar = Trt1cnt  x2axis;

  scatter y = subgroup x = trt2_lbl   / markerchar = Trt2cnt  x2axis;

  scatter y = subgroup x = or_lbl     / markerchar = OddRatio x2axis;

  scatter y = subgroup x = pval_lbl    / markerchar = pvalue   x2axis;

  refline 1 5 / axis = x;

  inset '           Favors Treatment' / position = bottomleft;

  inset 'Favors Control             ' / position = bottom;

  xaxis type = log offsetmin = 0.02 offsetmax = 0.35

        min = 0.05 max = 20 minor display = (nolabel) grid;

  x2axis offsetmin = 0.7 display = (noticks nolabel) offsetmax = 0.05;

  yaxis display = (noticks nolabel) offsetmin = 0.02 offsetmax = 0.02;

run;


Thanks

SAS Super FREQ
Posts: 8,866

Re: Forest Plot using SGPLOT

Posted in reply to sasjourney

Hi:

  Without a sample of YOUR data, it's impossible to understand what you mean. My suggestion is that you post this question, with code and data over in the ODS Graphics forum. Sanjay will look at and answer questions that are posted over there, and since he is the author of all the FOREST plot examples that I know of, he's the expert in this area.

cynthia

Super User
Posts: 11,343

Re: Forest Plot using SGPLOT

Posted in reply to sasjourney

One of the classic ways is to add a value in each sub group with an associated y value of missing or zero. Playing some games with the value formats to indicate a blank or possibly just a vertical line to indicate a spacer is often possible. Just make sure that the added subgroup value is either last or first in value.

Contributor
Posts: 43

Re: Forest Plot using SGPLOT

Thanks Ballard.

I did try that approach by plugging in a blank record after each subgroup, but I was not able to get that extra blank (Maybe because the oddsratio, which I was trying to plot is missing).

Thanks

Super User
Posts: 11,343

Re: Forest Plot using SGPLOT

Posted in reply to sasjourney

By "blank record" do you mean all values missing? or just the results?

Contributor
Posts: 43

Re: Forest Plot using SGPLOT

Sorry, I meant just the results..I have everything else populated.

Thanks

Ask a Question
Discussion stats
  • 8 replies
  • 469 views
  • 0 likes
  • 3 in conversation