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;
BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
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.

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1346 views
  • 6 likes
  • 3 in conversation