Data visualization with SAS programming

How to edit this forest plot code to accommodate a non-log scale?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

How to edit this forest plot code to accommodate a non-log scale?

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


Accepted Solutions
Solution
‎12-01-2015 05:03 AM
Trusted Advisor
Posts: 1,114

Re: How to edit this forest plot code to accommodate a non-log scale?

[ Edited ]

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


All Replies
Solution
‎12-01-2015 05:03 AM
Trusted Advisor
Posts: 1,114

Re: How to edit this forest plot code to accommodate a non-log scale?

[ Edited ]

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.

Occasional Contributor
Posts: 7

Re: How to edit this forest plot code to accommodate a non-log scale?

Thanks so much!
Post a Question
Discussion Stats
  • 2 replies
  • 256 views
  • 1 like
  • 2 in conversation