Hi all
I attach the code and the resulting figure
proc sgplot data=aha.forest noautolegend nocycleattrs;
styleattrs datasymbols=(squarefilled);
scatter y=predictors x=or / xerrorupper=ucl xerrorlower=lcl group=grp;
yaxistable or lcl ucl p / y=predictors location=inside position=right;
refline 1 / axis=x noclip;
xaxis type=log max=10 minor display=(nolabel) valueattrs=(size=7) valuesformat=f2.0;
yaxis display=(noticks nolabel) fitpolicy=none reverse valueshalign=left
colorbands=even colorbandsattrs=Graphdatadefault(transparency=0.8) valueattrs=(size=7);
run;
I need to amplify the x axis around 1 (let's say from 1.01 to 1.1) and then restart with a log scale.
Can you help me please?
Tks in advance
Antonio
Are you saying you want the range 1.01 to 1.1 to be on a linear scale?
Hi @antor82,
Would it help to create a broken x-axis? Last week, @BrunoMueller posted a nice solution demonstrating how this can be done. Here's my attempt to adapt his code to your requirements:
/* Store repetitive code elements in macro variables */
%let plot=scatterplot x=or y=predictors / subpixel=off primary=true group=grp
xerrorupper=ucl xerrorlower=lcl legendlabel="predictors" name="scatter";
%let xopts=type=log griddisplay=on display=(ticks tickvalues) tickvalueattrs=(size=7);
%let yopts=reverse=true labelfitpolicy=split tickvalueattrs=(size=7) tickvaluehalign=left type=discrete
discreteopts=(tickvaluefitpolicy=none colorbands=even
colorbandsattrs=graphdatadefault(transparency=0.8));
/* Create the GTL template with a manually broken x-axis */
proc template;
define statgraph forest_break;
begingraph / datasymbols=(squarefilled);
/* the column weights determine the space available */
layout lattice / columns=3 rowdatarange=union columnweights=(0.35 0.25 0.4) ;
layout overlay /
xaxisopts=(&xopts logopts=(viewmin=0.6 viewmax=0.8
minorticks=true tickvaluelist=(0.6 0.7 0.8)))
yaxisopts=(display=(tickvalues line) &yopts)
y2axisopts=(labelFitPolicy=Split);
&plot;
endlayout;
layout overlay /
xaxisopts=(&xopts logopts=(viewmin=0.9 viewmax=1.11
minorticks=true tickvaluelist=(0.9 0.95 1 1.05 1.1))
offsetmin=0.02)
yaxisopts=(display=none &yopts);
&plot;
ReferenceLine x=1 / clip=false;
endlayout;
layout overlay /
xaxisopts=(&xopts logopts=(viewmin=1.16 viewmax=10
minorticks=true tickvaluelist=(1.2 2 3 4 5 6 7 8 9 10))
offsetmin=0.0075)
yaxisopts=(display=none &yopts);
&plot;
innermargin / align=right;
axistable value=or y=predictors / labelposition=min display=(label);
axistable value=lcl y=predictors / labelposition=min display=(label);
axistable value=ucl y=predictors / labelposition=min display=(label);
axistable value=p y=predictors / labelposition=min display=(label);
endinnermargin;
endlayout;
endlayout;
endgraph;
end;
run;
/* Use the template to create the graph */
ods graphics / reset=all;
proc sgrender data=aha.forest template=forest_break;
run;
Result (omitting the titles for brevity):
(Note the spelling of the word "length".)
Thank You so much. This is an impressive improvement!!!
I've corrected the spelling in the original dataset (tks for Your attention!!!)
Unfortunately, I'm not able to:
1) keep the x-asix values in the format You posted (please refer to the attached figure for my mistake=too much decimals! and some values missing compared to Your figure)
2) put three titles inside the full image (as it was in my previously attached file).
Would You mind help me, please?
Sincerely
Antonio
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.