BookmarkSubscribeRSS Feed
sasjourney
Calcite | Level 5

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

8 REPLIES 8
ballardw
Super User

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.

Cynthia_sas
SAS Super FREQ

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
sasjourney
Calcite | Level 5

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

Cynthia_sas
SAS Super FREQ

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

ballardw
Super User

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.

sasjourney
Calcite | Level 5

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

ballardw
Super User

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

sasjourney
Calcite | Level 5

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

Thanks

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1871 views
  • 0 likes
  • 3 in conversation