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
Given Hedge's g values ranging from -2 to 8, my first attempt would be:
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.
Given Hedge's g values ranging from -2 to 8, my first attempt would be:
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.