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
Forgot to mention SAS 9.4M3
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.
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.
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.