BookmarkSubscribeRSS Feed
ANWZimmerman
Obsidian | Level 7

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

5 REPLIES 5
ANWZimmerman
Obsidian | Level 7

Forgot to mention SAS 9.4M3

Jay54
Meteorite | Level 14

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.

ballardw
Super User

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.

ANWZimmerman
Obsidian | Level 7

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.

Jay54
Meteorite | Level 14

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 1509 views
  • 0 likes
  • 3 in conversation