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

Are the upside and rightside ticks available in GPLOT/SGPLOT?

1.png

In the following, I added the rightside ticks manually, but wonder whether there is any embedded function.

data _;
do x=0 to 6.28 by 0.01;
y=sin(x);
output;
end;
run;
symbol1 i=join;
symbol2 i=none;
axis1 order=(-1 to 1 by 1) minor=none;
axis2 order=(0 to 6.28 by 1.57) minor=none;
proc gplot;
plot1 y*x/vaxis=axis1 haxis=axis2 nofr;
plot2 y*x/vaxis=axis1 haxis=axis2 nofr overlay;
run;
quit;

2.png

1 ACCEPTED SOLUTION
3 REPLIES 3
GraphGuy
Meteorite | Level 14

With gplot, you can add a 'plot2' to get an axis on the right-hand side. I typically plot the same data a 2nd time, but use a blank/invisible marker value and line interpolation.

 

symbol1 value=none interpol=join color=blue;
symbol2 value=none interpol=none color=white;


axis1 order=(0 to 225 by 25) minor=none offset=(0,0);
axis2 label=none order=('01jan1990'd to '01jan2000'd by year) minor=none;

 

title1 ls=1.5 h=20pt "IBM Stock Price";
proc gplot data=sashelp.stocks (where=(stock='IBM'));
format date year4.;
plot close*date=1 / vaxis=axis1 haxis=axis2;
plot2 close*date=2 / vaxis=axis1 haxis=axis2;
run;

 

gplot12.png

GraphGuy
Meteorite | Level 14

Here's one way to get an axis on the right-side with sgplot:

 

title1 ls=1.5 h=20pt "IBM Stock Price";

 

proc sgplot data=sashelp.stocks (where=(stock='IBM')) noautolegend;
format date year4.;
series y=close x=date / lineattrs=(color=blue);
scatter y=close x=date / y2axis markerattrs=(size=0px color=blue symbol=circlefilled);
yaxis values=(0 to 225 by 25);
y2axis values=(0 to 225 by 25);
xaxis display=(nolabel) values=('01jan1990'd to '01jan2000'd by year);
run;

 

SGPlot15.png

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 859 views
  • 0 likes
  • 3 in conversation