I'm creating a scatterplot using sgplot. My points have both positive and negative values. I would like to draw two axes through (0,0), but keep the axis labels at the edge of the graph. What's the best way to do this? (I know I can use lineparm, but I'm hoping there is a simpler option).
I'll let someone else advice as to how it might be accomplished. In my opinion, you shouldn't do it. The center of the plot should be reserved for the data, with the axis ticks, values, and labels positioned to the outside. This is based on basic principles of graphing (a la Tufte) which state that the data should be presented as purely and unadorned as possible.
Another thought: To obtain a whole grid of reference lines, where each line is aligned with axes ticks, use the GRID option on the XAXIS and YAXIS statements, like this:
xaxis grid; yaxis grid;
That gives you all of the advantages of axes that cut through the plot area, but keeps the tick values and labels on the outside of the plot area.
I don't think there is a way to do this in SGPLOT. However, you can do this using GTL.
In your case, your data would span across (0, 0), and you would set the x and y origins at zero.
define statgraph class;
entrytitle 'Weight by Height for all Students';
layout overlay / xaxisopts=(linearopts=(origin=60))
scatterplot x=height y=weight / group=sex name='a';
proc sgrender data=sashelp.class template=class;
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.
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.