BookmarkSubscribeRSS Feed
rafikghazaryan9
Calcite | Level 5

Hi
In my graph I need to display Y axis -8 to 8 by 2 but need horizontal grid lines -8 to 8 by 1 with no label.
Any ideas?

Thanks

5 REPLIES 5
Reeza
Super User
You can control most of that with the YAXIS statements. Try REFTICKS and the GRID option and DISPLAY= to control the labels/texts. What have you tried so far?

https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=p07m2vpyq75fgan14m6g5pphnwlr.htm&doc...
rafikghazaryan9
Calcite | Level 5
Dear Reeza
I tried using grid gridvalues options. Did not help.
I need to display in Y axis -8 -6 -4 -2 0 2 4 6 8 but grid lines need for -8 -7 -6 -5 ...... 8 and without labeling odd points
Reeza
Super User
Can you post an example of what you've tried perhaps with the sashelp.class data set so we can try it as well? Note the options I've stated above so far.
Jay54
Meteorite | Level 14

One "simplistic" way is to set y-axis values=(-8 to 8 by 2) with grid option.  Then add y reflines at the other places and set the refline attributes to the same as the grid lines.

 

  refline -7 -5 -3 -1 1 3 5 7 / lineattrs=graphgridlines;

 

or, just draw the reflines for all values, or from a column that has these values as observations. 

 

proc sgplot data=sashelp.class;
scatter x=height y=weight;
yaxis values=(0 to 200 by 40) grid;
refline 20 60 100 140 180 / lineattrs=graphgridlines;
run;

Rick_SAS
SAS Super FREQ

I want to add to Sanjay's example by mentioning that you can use the SEQUENCE notation on the REFLINE statement as well:

 

refline (-7 to 7 by 2) / lineattrs=graphgridlines;

 

or

 

refline (20 to 180 by 40) / lineattrs=graphgridlines;

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
  • 5 replies
  • 6088 views
  • 2 likes
  • 4 in conversation