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 2024

Innovate_SAS_Blue.png

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