BookmarkSubscribeRSS Feed
Quentin
Super User

Hi All,

I'm using SAS 9.3 GTL to make a graph that overlays a box plot and a series plot.  The series plot uses curvelabel with curvelocation=inside curvelabelposition=end.  Problem is that sometimes the label for the series appears on top of the last box. (collision of sorts) I would like it to appear in white space to the right.

Is there some way for me to offset the curvelabel a bit to the right, so that it would not overlay the box (without using curvelocation=outside)?  I guess this could be hard, because the seriesplot doesn't know about the boxplot.  I can't use curvelocation=outside because in real code this graph is part of a layout lattice cell.

Would settle for hard coding some non-printable white space character, if there is a good way to do that, which would work for html/pdf/rtf destinations.  Something like "curvelabel=%str(    )Limit".

Sample code below.

Thanks,

--Q.


proc template;
  define statgraph TryBox;
    begingraph;
      layout overlay;
          boxplot x=sex y=Height ;      
          seriesplot x=sex y=LimitLine /
             curvelabel="Limit"  
             curvelabellocation=inside
             curvelabelposition=end
          ; 

      endlayout;
    endgraph;
  end;
run;

data class;
  set sashelp.class;
  LimitLine=60;
run;
proc sort data=class;by sex;run;
proc sgrender data=class template=TryBox;
run;
The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
3 REPLIES 3
ballardw
Super User

With 9.3 I would look up annotating graphs. The annotate facility will let you pick locations and text displayed.

Or Start by generating the graph, without the curvelabel, use the ODS graphics editor to add the text desired.

Jay54
Meteorite | Level 14

One quick fix for this case is to use enough leading non-breaking spaces in your curve label.  I create a label with  20 leading nbsp.  But that takes your label far from the line itself.  Maybe use a legend to identify the line?

data _null_;BoxLabel1.png

  lbl='....................Limit';

  lbl=translate(lbl, 'A0'x, '.');

  call symput ("lbl", lbl);

  run;

proc template;

  define statgraph TryBox;

    begingraph;

      layout overlay;

          boxplot x=sex y=Height ;     

          seriesplot x=sex y=LimitLine /

             curvelabel="&lbl" 

             curvelabellocation=inside

             curvelabelposition=end

          ;

      endlayout;

    endgraph;

  end;

run;

data class;

  set sashelp.class;

  LimitLine=60;

run;

proc sort data=class;by sex;run;

proc sgrender data=class template=TryBox;

run;

Quentin
Super User

Thanks Sanjay, I'll play with that. In the real setting the boxes are narrower, so I should only need a handful of non-breaking spaces.  The labels should be close enough.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 1587 views
  • 6 likes
  • 3 in conversation