Hi All,
I am working on sgplot barline chart . I am trying to display barline chart with two legends one for the bars and other for line . I want to have the legend values for line chart different from the group xyz .
Below is the code.
proc sgplot data=xxxx;
vline b/response=a group=xyz groupdisplay=cluster y2axis legend=legend1 name="b" ;
vbar b/response=c group=xyz groupdisplay=cluster name="a" ;
keylegend "a" "b";
run;
Is there a way where I can change the values of the legend for the vline ?
Thanks.
I too am trying to understand your use case. Combining plot statements gets a lot easier if you pre summarize your data (Proc Means), and then use VBARPARM and SERIES plots. Then, you can use different category and group variables as needed. With VBAR and VLINE, there are some restrictions. Which release of SAS are you using?
To get two legend, you code should look like the following:
proc sgplot data=xxxx;
vline b/response=a group=xyz groupdisplay=cluster y2axis name="b" ;
vbar b/response=c group=xyz groupdisplay=cluster name="a" ;
keylegend "a";
keylegend "b";
run;
What values do you want for the line chart?
Hi Dan,
Thanks for the response. For line chart I am getting the group variable names of xyz in the legend "b" and I want to rename those values .
For example :
if the group xyz consists of ab, bc ,cd
I would get the same naming conventions in both the legends . I cant change the group name in line charts as it a summarized plot.
Thanks.
I'm not quite cleat on what you're after. Are you wanting the line chart and bar chart to represent a different set of values from the same group variable?
Exactly I want to represent different set of values for the same group variable.
I too am trying to understand your use case. Combining plot statements gets a lot easier if you pre summarize your data (Proc Means), and then use VBARPARM and SERIES plots. Then, you can use different category and group variables as needed. With VBAR and VLINE, there are some restrictions. Which release of SAS are you using?
Hi Sanjay,
Thanks for the info will try with vbarparm . I am using sas 9.4.
Thanks,
Sundeep.
Hi Sanjay,
Thanks for the help. It worked for me .
Thanks,
Sundeep.
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.
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.