BookmarkSubscribeRSS Feed
bc
Calcite | Level 5 bc
Calcite | Level 5

I am using proc template with layout lattice to create 2 side by side ROC figures, each figure having several overlayed lines. The problem I am having is that the same legend is placed under each figure - which is ok for identifying the different groups, except that the legend text also includes the AUC value, which of course will be different depending on the figure. In short, can someone refer me to a reference on how to create a custom legend? I'm using 9.2.
Thanks.

3 REPLIES 3
PrashantH_sas
SAS Employee

Hi,

Custom legend support is available in SAS 9.3 via the LEGENDITEM statement in the Graph Template Language.

Can you point to an example output and/or template code to see if we can suggest a solution for SAS 9.2 ?

With Regards,

-Prashant.

bc
Calcite | Level 5 bc
Calcite | Level 5

Template code looks like this:

define statgraph Graphics.ROCOverlay; 

  notes "Receiver Operating Characteristic Overlaid Curves";

  dynamic _TITLE1 ;

  BeginGraph;

  entrytitle _TITLE1;

 

  layout lattice / columns=2 columngutter=0 columnweights=(0.5 0.5)  ;  

   layout overlayequated /

    equatetype = square

    yaxisopts = (gridDisplay=off label="Sensitivity" shortlabel = "TPR" offsetmin=0.05 offsetmax=0.05)

    xaxisopts = (gridDisplay=off label="1 - Specificity" shortlabel="FPR" offsetmin=0.05 offsetmax=0.05)

    commonaxisopts = ( tickvaluelist=(0 .25 .5 .75 1) viewmin = 0 viewmax = 1)

    ;

  /* Trt1 Curves */

    entry halign=center "Trt 1"/location=outside valign=TOP;

    lineparm x=0 y=0 slope=1 /

      extend = true

      lineattrs =( color = grey thickness = 1.5px)

    ; 

    seriesplot y =_SENSIT_ x=_1MSPEC_ /

      connectorder = xaxis

      tip = (group y x)

      group = _ROC_

      index = _GROUP_

      name = "Step"

      primary = true

      lineattrs = (thickness = 1px)

    ; 

     /* Legend Defn */

          discretelegend "Step" / Title = "ROC Curve (Area)"

      LOCATION = /*INSIDE*/ outside

      HALIGN = /*RIGHT*/ Left

      VALIGN = BOTTOM

      PAD = (RIGHT = 2PX bottom = 2px)

      ORDER = ROWMAJOR

      ACROSS = 1

      BORDER = FALSE

      TITLEATTRS = (family = 'times' size = 8pt weight = BOLD)

      VALUEATTRS = (family = 'times' size = 7pt);

    ;

  endLayout;

  /* Placebo Curves */

  layOut overLayEquated /

    equatetype = square

    yaxisopts = (gridDisplay=off label="Sensitivity" shortlabel = "TPR" offsetmin=0.05 offsetmax=0.05)

    xaxisopts = (gridDisplay=off label="1 - Specificity" shortlabel="FPR" offsetmin=0.05 offsetmax=0.05)

    commonaxisopts = ( tickvaluelist=(0 .25 .5 .75 1) viewmin = 0 viewmax = 1)

    ;

    entry halign=center "Placebo"/location=outside valign=TOP;

    lineparm x=0 y=0 slope=1 /

      extend = true

      lineattrs =( color = grey thickness = 1.5px)

    ; 

    seriesplot y =pbo_SENSIT x=pbo_1MSPEC /

      connectorder = xaxis

      tip = (group y x)

      group = pbo_ROC

      index = pbo_GROUP

      name = "Step"

      primary = true

      lineattrs = (thickness = 1px)

    ; 

          discretelegend "Step" / Title = "ROC Curve (Area)"

      LOCATION = /*INSIDE*/ outside

      HALIGN = /*RIGHT*/ Left

      VALIGN = BOTTOM

      PAD = (RIGHT = 2PX bottom = 2px)

      ORDER = ROWMAJOR

      ACROSS = 1

      BORDER = FALSE

      TITLEATTRS = (family = 'times' size = 8pt weight = BOLD)

      VALUEATTRS = (family = 'times' size = 7pt);

    ;

  endlayout;

  endLayout; 

EndGraph;

end;

run;

DanH_sas
SAS Super FREQ

The problem is that both of your plots have the same name ("Step"). Change their names to be unique (e.g. "Step1" and "Step2"), and change the corresponding names in the DISCRETELEGEND statements. That should give you your unique legends.

Hope this helps!

Dan

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1669 views
  • 0 likes
  • 3 in conversation