BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shari
Calcite | Level 5

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.

 

Thanks in advance.

 



data temp;
input ptno ady value1 value2;
cards;
100 1 10 12
100 5 15 16
100 8 20 18
;


ods listing;
proc sgplot data=temp;
scatter x=ady y=value1/group=ptno;
scatter x=ady y=value2/y2axis group=ptno;
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;


1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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;
input ptno ady value1 value2;
cards;
100 1 10 12
100 5 15 16
100 8 20 18
;

ods listing;
proc sgplot data=temp;
scatter x=ady y=value1/group=ptno name="v1";
scatter x=ady y=value2/y2axis group=ptno name="v2";
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;

View solution in original post

2 REPLIES 2
DanH_sas
SAS Super FREQ

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;
input ptno ady value1 value2;
cards;
100 1 10 12
100 5 15 16
100 8 20 18
;

ods listing;
proc sgplot data=temp;
scatter x=ady y=value1/group=ptno name="v1";
scatter x=ady y=value2/y2axis group=ptno name="v2";
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;
shari
Calcite | Level 5
Thank you. It worked as expected. Sorry for not being much clear.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 21975 views
  • 1 like
  • 2 in conversation