BookmarkSubscribeRSS Feed
antor82
Obsidian | Level 7

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;

download.png

 

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

4 REPLIES 4
quickbluefish
Barite | Level 11

Are you saying you want the range 1.01 to 1.1 to be on a linear scale?  

antor82
Obsidian | Level 7
Maybe on a linear scale I will need a very large image to account for a clear visibility…. A double scale (linear at the beginning and log thereafter) could be more effective but I've read that this is not possible. I’ve tried a linear scale with broken axes but that gave me a very narrowed first part of the graph without any increase in visibility

FreelanceReinh
Jade | Level 19

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):

forest_break.png

(Note the spelling of the word "length".)

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 168 views
  • 6 likes
  • 3 in conversation