Hello. I need help with creating a forest plot. Here is a portion of the code:
layout overlay / xaxisopts=(type=log label=' | |--TRT More effective->' |
linearopts=(tickvaluepriority=true
tickvaluelist=(.5 1 2 3 4 5 6 7))logopts=(viewmin=.5 viewmax=7))
yaxisopts=(reverse=true display=none) walldisplay=none;
referenceline y=ref / lineattrs=(thickness=15 color=_color);
highlowplot y=subgroups low=ORlci high=ORuci / highcap=serif lowcap=serif;
scatterplot y=subgroups x=ORest / markerattrs=(symbol=diamondfilled);
referenceline x=.5 / lineattrs=(pattern=shortdash);
referenceline x=1;
referenceline x=2 / lineattrs=(pattern=shortdash);
referenceline x=3 / lineattrs=(pattern=shortdash);
referenceline x=4 / lineattrs=(pattern=shortdash);
referenceline x=5 / lineattrs=(pattern=shortdash);
referenceline x=6 / lineattrs=(pattern=shortdash);
endlayout;
I can't seem to get the .5 to show up on the xaxis. Any suggestions/fix?
That is because there is no such option for the LOGOPTS (see doc). Due to the unequal placement of the log tick values, some values are thinned.
A work around would be to draw your own tick values. To do this, you can use either a BLOCKPLOT or a SCATTER with MARKERCHARACTER to draw these values. You will have to put the values you want in a data column and use this statement in another cell at the bottom and turn off the axis for the main cell. If this is important, you will have to experiment with this a bit.
Alternately, use the SGPLOT to draw the Forest Plot, and use SGAnnotate to place the ticks and tick values.
If you attach your full code with data, I could make some suggestions.
It is hard to say without the resulting graph or the full program code with data. Which release of SAS are you using?
You are using TYPE=log, but TickValueList is specified in the LinearOpts. It will not apply to Log axis. You have to provide that in LogOpts. Does it show all ticks if you set Type=Linear and LinearOpts=(TickVlaueFitPolicy=none)?
I'm using 9.3
I tried type=linear and linearopts with tickvaluefitpolicy=none and it showed all values.
However, I would like to do this in the log scale. I'm getting an error when trying this:
layout overlay / xaxisopts=(type=log label='more effective-->'
logopts=(tickvaluelist=(.5 1 2 3 4 5 6 7) TickVlaueFitPolicy=none))
ERROR 22-322: Syntax error, expecting one of the following: ), BASE, MINORTICKS, THRESHOLDMAX,
THRESHOLDMIN, TICKINTERVALSTYLE, VIEWMAX, VIEWMIN.
ERROR 76-322: Syntax error, statement will be ignored.
That is because there is no such option for the LOGOPTS (see doc). Due to the unequal placement of the log tick values, some values are thinned.
A work around would be to draw your own tick values. To do this, you can use either a BLOCKPLOT or a SCATTER with MARKERCHARACTER to draw these values. You will have to put the values you want in a data column and use this statement in another cell at the bottom and turn off the axis for the main cell. If this is important, you will have to experiment with this a bit.
Alternately, use the SGPLOT to draw the Forest Plot, and use SGAnnotate to place the ticks and tick values.
If you attach your full code with data, I could make some suggestions.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.