BookmarkSubscribeRSS Feed
Calcite | Level 5

I'm trying to create a graph that has one variable (Y1) on the positive part of the Y-axis, and another variable (Y2) on the negative part of the Y-axis. Both Y1 and Y2 has the X-axis in common.

If its possible I want both Y1 and Y2 to seperatly go towards positive infinity.

My question: How do I create this Y1 Y2 thing? Preferably in proc gplot if you have the expertise to help me out with some guidence or a keyphrase that I can continue googling with 🙂

Thank you in advance,
Meteorite | Level 14
You'll want to google for the keywords 'gplot' and 'overlay', I believe.
Quartz | Level 8
Before you call GPLOT, you should create a new variable that has Y1 and Y2 combined properly.
Calcite | Level 5
In what way do you mean 'properly'?
Quartz | Level 8
In what way do you mean "I'm trying to create a graph that has one variable (Y1) on the positive part of the Y-axis, and another variable (Y2) on the negative part of the Y-axis"??

More detail would help.
Calcite | Level 5
Sorry, my bad.

I created a picture to illustrate what I want to do:

The orange (unnamed) variable is the one I'm having difficulties with.
Var1-Var3 and the "orange" variable are recorded over time and I want to be able to see what happens with the other variables (var1-var3) when the "orange" changes.

The infinity marks are just there to point out that I want to have both Y1 and Y2 to be positive regarding vertical direction from origo.

Thank you.
Meteorite | Level 14
data foo;
input x var1 var2 var3 var4;
1 1 2 4 -3
2 .5 3 4 -3
3 .1 2 4 -4
4 .01 1 3.5 -4

axis1 label=none value=none order=(-5 to 5 by 1) major=none minor=none;
axis2 label=none value=none major=none minor=none;

symbol1 value=none interpol=sm50 color=blue;
symbol2 value=none interpol=sm50 color=red;
symbol3 value=none interpol=sm50 color=green;
symbol4 value=none interpol=steplj color=orange;

proc gplot data=foo;
plot var1*x=1 var2*x=2 var3*x=3 var4*x=4 / overlay
vaxis=axis1 vref=0 cvref=black wvref=2 haxis=axis2 noframe;
Calcite | Level 5
Thank you! Much appreciated! 🙂



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 7 replies
  • 3 in conversation