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.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
  • 1826 views
  • 0 likes
  • 3 in conversation