Data visualization with SAS programming

MERGEDLEGEND

Accepted Solution Solved
Reply
Contributor
Posts: 50
Accepted Solution

MERGEDLEGEND

I have the following

      seriesplot  x=eval(atptn-13*&offx) y=mean1 /   lineattrs=graphdata1(color=blue pattern=shortdash thickness=2) name='series1' legendlabel="Drug A";

      scatterplot x=eval(atptn-13*&offx) y=mean1/     YErrorUpper=High1 YErrorLower=Low1

                  markerattrs=graphdata1(color=blue symbol=trianglefilled size=9) errorbarattrs=graphdata1(color=blue pattern=solid)

                  name='scatter1' legendlabel="Drug A";

      seriesplot  x=eval(atptn-11*&offx) y=mean2 /   lineattrs=graphdata2(color=red pattern=mediumdash  thickness=2) name='series2' legendlabel="Drug B";

      scatterplot x=eval(atptn-11*&offx) y=mean2 /    YErrorUpper=High2 YErrorLower=Low2

                  markerattrs=graphdata2(color=red symbol=starfilled size=9) errorbarattrs=graphdata2(color=red pattern=solid)

                  name='scatter2' legendlabel="Drug B";

How do I use Mergedlegend statement for the above case

Currently Im using it in a following way

mergedlegend 'series1' 'scatter1' 'series2' 'scatter2' / across=1 location=inside halign=right valign=top;

But it is not working !!


Accepted Solutions
Solution
‎05-10-2015 06:12 PM
SAS Super FREQ
Posts: 1,080

Re: MERGEDLEGEND

You can certainly place multiple legends in a Layout Gridded  or Lattice, one each with the two associated Scatter and Series plots.   With SAS 9.4, you can use a Layout GlobelLegend within which you can place the individual MergedLegends.  Use AutoAlign or HAlign and VAlign.

Layout Overlay;

  SeriesPlot...;

  Scatterplot...;

  SeriesPlot...;

  Scatterplot...;

  Layout Gridded / halign=   valign= ;

    mergedlegend 'series1' 'scatter1' / <options>;

    mergedlegend 'series2' 'scatter2' / <options>;

  endlayout;

endlayout;

View solution in original post


All Replies
SAS Super FREQ
Posts: 1,080

Re: MERGEDLEGEND

For MergedLegend, you can use only 2 statement names as required parameters.  See Doc:

"The MERGEDLEGEND statement can be used to consolidate legend entries when the graph displays grouped data for two plots. The statement must specify exactly two names that reference the source for the legend entry values."

Contributor
Posts: 50

Re: MERGEDLEGEND

Thanks Sanjay for your reply, Yes I have seen this in the documentation! In that case, this is a kind of limitation for MERGEDLEGEND! Is there any other way I can achieve this?

Solution
‎05-10-2015 06:12 PM
SAS Super FREQ
Posts: 1,080

Re: MERGEDLEGEND

You can certainly place multiple legends in a Layout Gridded  or Lattice, one each with the two associated Scatter and Series plots.   With SAS 9.4, you can use a Layout GlobelLegend within which you can place the individual MergedLegends.  Use AutoAlign or HAlign and VAlign.

Layout Overlay;

  SeriesPlot...;

  Scatterplot...;

  SeriesPlot...;

  Scatterplot...;

  Layout Gridded / halign=   valign= ;

    mergedlegend 'series1' 'scatter1' / <options>;

    mergedlegend 'series2' 'scatter2' / <options>;

  endlayout;

endlayout;

Contributor
Posts: 50

Re: MERGEDLEGEND

Thanks you so much Sanjay this is very helpful and I've seen layout globallegend but not gridded which plots outside the graph!

Anyway this works to me !! Thanks!!!

SAS Super FREQ
Posts: 1,080

Re: MERGEDLEGEND

You can nest a Layout Gridded inside the Layout Overlay (like I showed earlier) if you want to place the legend inside the data area.  Or you can place it outside using Layout GlobelLegend, or Gridded or Lattice.  It depends on how you structure your template.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 532 views
  • 6 likes
  • 2 in conversation