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-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!

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.

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
  • 2 replies
  • 1219 views
  • 1 like
  • 2 in conversation