Data visualization with SAS programming

SAS SGPLOT BARLINE CHART

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

SAS SGPLOT BARLINE CHART


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.


Accepted Solutions
Solution
‎02-28-2015 02:24 AM
SAS Super FREQ
Posts: 1,079

Re: SAS SGPLOT BARLINE CHART

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?

View solution in original post


All Replies
SAS Super FREQ
Posts: 888

Re: SAS SGPLOT BARLINE CHART

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?

Contributor
Posts: 24

Re: SAS SGPLOT BARLINE 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.

SAS Super FREQ
Posts: 888

Re: SAS SGPLOT BARLINE CHART

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?

Contributor
Posts: 24

Re: SAS SGPLOT BARLINE CHART

Exactly I want to represent different set of values for the same group variable.

Solution
‎02-28-2015 02:24 AM
SAS Super FREQ
Posts: 1,079

Re: SAS SGPLOT BARLINE CHART

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?

Contributor
Posts: 24

Re: SAS SGPLOT BARLINE CHART

Hi Sanjay,

                  Thanks for the info will try with vbarparm . I am using sas 9.4.

Thanks,

Sundeep.

Contributor
Posts: 24

Re: SAS SGPLOT BARLINE CHART

Hi Sanjay,

                   Thanks for the help. It worked for me Smiley Happy.

Thanks,

Sundeep.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 664 views
  • 1 like
  • 3 in conversation