Data visualization with SAS programming

GTL Missing Legend

Reply
Contributor
Posts: 26

GTL Missing Legend

What am I missing? I'm putting a bar chart together with a line graph, both have months for the X axis, so that totally works.  I'm getting exactly what I want, except I'm getting no legend, I was expecting a legend that distinguished the different lines from the series plot.

 

proc template;

   define statgraph vbar_line;

   dynamic _title _Xbar _Ybar _xseries _yseries _seriesGroup _seriesTitle;

      begingraph;

         entrytitle _title;

         layout overlay/xaxisopts=(type=time timeopts=(interval=quarter TICKVALUEFORMAT=MONYY5.))

                       yaxisopts=(type=linear linearopts=(tickvalueformat=(EXTRACTSCALE=TRUE)))

                       y2axisopts=(type=linear linearopts=(tickvalueformat=percent8.1));

            barchart x=_xbar y=_ybar/ yaxis=y;

            seriesplot x=_xseries y=_yseries / group=_seriesGroup name="series" yaxis=y2

                                               lineattrs=(pattern=solid thickness=3);

            discretelegend "series"/title=_seriesTitle;

         endlayout;/*overlay*/

      endgraph;

   end;/*define statgraph*/

run;

 

Thanks

Contributor
Posts: 26

Re: GTL Missing Legend

Forgot to mention SAS 9.4M3

SAS Super FREQ
Posts: 1,044

Re: GTL Missing Legend

Did you check for log messages?  If you have a large number of groups, the legend may get too big to display by default.  You can increase the space allowed for the legend.  Please include full program with data that can be shared so we can run the case and see what is happening.

Grand Advisor
Posts: 9,748

Re: GTL Missing Legend

You might want to show the code of SGRender used with the template, and possibly some example data.

I am assuming you get no warnings or errors when building the template.

Contributor
Posts: 26

Re: GTL Missing Legend

I'm pretty sure the problem is too many groups.  I only have 5 lines, I only calculated the percent for the lines for the 5 groups that I need, but it appears SAS is trying to put all the groups in the legend even though there are no lines drawn for them.

 

I'm having to alter the data a lot, but I'm able to get what I need by eliminating the grouping variable on the rows for data that don't contribute to the 5 lines I want (but I can't delete the rows of data wholly because they contribute to the bar chart)

 

Thanks, no errors in the log, this was a tricky one, I figured 5 should be able to fit in the legend, didn't know it was trying to all the other groups.

SAS Super FREQ
Posts: 1,044

Re: GTL Missing Legend

It is not an ERROR in the log.  There will be a NOTE or WARNING about legend being dropped due to it getting too big.

Post a Question
Discussion Stats
  • 5 replies
  • 245 views
  • 0 likes
  • 3 in conversation