BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
j4ne
Fluorite | Level 6

I want to create a version of the forest plot here: http://support.sas.com/kb/42/867.html

Unfortunately, the scale isn't useful for the values I want to include (Hedge's g instead of odds ratio), which range from ~-2 to +8. If I include a negative number in the datalines, the whole plot becomes unreadable.

Is it possible to rejig the code to accommodate the scale? I'm not overly familiar with SAS, so my coding skills are fairly limited.

Part of the code that I've tried editing to no avail:

 

proc sgplot data=forest4 noautolegend;
scatter y=study2value x=oddsratio / markerattrs=graphdata2(symbol=diamondfilled size=10);
scatter y=studyvalue x=oddsratio / xerrorupper=ucl2 xerrorlower=lcl2 markerattrs=graphdata1(symbol=squarefilled size=0);
vector x=x2 y=studyvalue / xorigin=x1 yorigin=studyvalue lineattrs=graphdata1(thickness=8) noarrowheads;
scatter y=studyvalue x=or / markerchar=oddsratio x2axis;
scatter y=studyvalue x=lcl / markerchar=lowercl x2axis;
scatter y=studyvalue x=ucl / markerchar=uppercl x2axis;
scatter y=studyvalue x=wt / markerchar=weight x2axis;
refline 1 100 / axis=x;
refline 0.1 10
/ axis=x lineattrs=(pattern=shortdash) transparency=0.5;
inset ' Favors Treatment' / position=bottomleft;
inset 'Favors Placebo' / position=bottom;
xaxis type=log offsetmin=0 offsetmax=0.35 min=0.01 max=100 minor display=(nolabel) ;
x2axis offsetmin=0.7 display=(noticks nolabel);
yaxis display=(noticks nolabel) offsetmin=0.1 offsetmax=0.05 values=(1 to &count by 1);
run;

 

Many thanks for any help

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Given Hedge's g values ranging from -2 to 8, my first attempt would be:

  1. Delete "type=log" from the XAXIS statement. (Only positive values are suitable for a logarithmic scale.)
  2. In the same line change 0.01 to a value slightly less than the minimum g value in your data (or rather the minimum LCL), e.g. -3, and 100 to a value slightly greater than the maximum value in your data (or the maximum UCL, respectively), e.g. 9.
  3. Remove the REFLINE statements or change the values 1, 100, 0.1, 10 to values which make sense on the new scale from -3 to 9 (what about 0?). So, maybe a single refline statement refline 0 / axis=x; would be sufficient.
  4. Similarly, remove or replace the INSET statements.
  5. Of course, all references to odds ratios in the plot should be replaced by references to Hedge's g.

Possibly you don't like the tick mark values that SAS determines automatically (e.g. -2.5, 0.0, 2.5, etc.) and you would prefer tick marks at -3, -2, -1, etc. In this case you can replace the specification "min=-3 max=9" in the XAXIS statement by "values=(-3 to 9)". Furthermore, you can drop the keyword "minor" if you don't need the unlabeled smaller tick marks between the major tick marks.

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Given Hedge's g values ranging from -2 to 8, my first attempt would be:

  1. Delete "type=log" from the XAXIS statement. (Only positive values are suitable for a logarithmic scale.)
  2. In the same line change 0.01 to a value slightly less than the minimum g value in your data (or rather the minimum LCL), e.g. -3, and 100 to a value slightly greater than the maximum value in your data (or the maximum UCL, respectively), e.g. 9.
  3. Remove the REFLINE statements or change the values 1, 100, 0.1, 10 to values which make sense on the new scale from -3 to 9 (what about 0?). So, maybe a single refline statement refline 0 / axis=x; would be sufficient.
  4. Similarly, remove or replace the INSET statements.
  5. Of course, all references to odds ratios in the plot should be replaced by references to Hedge's g.

Possibly you don't like the tick mark values that SAS determines automatically (e.g. -2.5, 0.0, 2.5, etc.) and you would prefer tick marks at -3, -2, -1, etc. In this case you can replace the specification "min=-3 max=9" in the XAXIS statement by "values=(-3 to 9)". Furthermore, you can drop the keyword "minor" if you don't need the unlabeled smaller tick marks between the major tick marks.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1440 views
  • 1 like
  • 2 in conversation