Solved
New Contributor
Posts: 3

# proc sgplot with 2 y axes

Hi,

I am trying to create a plot with two y axes. I used proc sgplot and I see the graph generated with color and symbol representation for only one y axis. Is there any way or option to show the color and symbol representation for another Y axis.

``````

data temp;
cards;
100 1 10 12
100 5 15 16
100 8 20 18
;

ods listing;
proc sgplot data=temp;
yaxis min=0 label='Y1 axis' values=(0 to 20 by 2);
y2axis min=0 label='Y2 axis' values=(0 to 20 by 2);
run;

``````

Accepted Solutions
Solution
‎04-12-2018 08:17 PM
SAS Super FREQ
Posts: 1,047

## Re: proc sgplot with 2 y axes

I'm not entirely sure of what you want, but I think you might want separate legends for each plot. Here is an example:

``````data temp;
cards;
100 1 10 12
100 5 15 16
100 8 20 18
;

ods listing;
proc sgplot data=temp;
keylegend "v1" / title="Y Axis" position=bottomleft;
keylegend "v2" / title="Y2 Axis" position=bottomright;
yaxis min=0 label='Y1 axis' values=(0 to 20 by 2);
y2axis min=0 label='Y2 axis' values=(0 to 20 by 2);
run;``````

All Replies
Solution
‎04-12-2018 08:17 PM
SAS Super FREQ
Posts: 1,047

## Re: proc sgplot with 2 y axes

I'm not entirely sure of what you want, but I think you might want separate legends for each plot. Here is an example:

``````data temp;
cards;
100 1 10 12
100 5 15 16
100 8 20 18
;

ods listing;
proc sgplot data=temp;
keylegend "v1" / title="Y Axis" position=bottomleft;
keylegend "v2" / title="Y2 Axis" position=bottomright;
yaxis min=0 label='Y1 axis' values=(0 to 20 by 2);
y2axis min=0 label='Y2 axis' values=(0 to 20 by 2);
run;``````
New Contributor
Posts: 3

## Re: proc sgplot with 2 y axes

Thank you. It worked as expected. Sorry for not being much clear.
☑ This topic is solved.