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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.