BookmarkSubscribeRSS Feed
Vic3
Obsidian | Level 7

Is there a maximum frequency for gridlines in proc sgplot?

The following command draws gridlines every 100 units as it should:

              xaxis grid values=(56000 to 57000 by 100);

However, if I decrease the spacing to 50 such as this:

              xaxis grid values=(56000 to 57000 by 50);

the grid spacing on the graph remains at 100.

I played around with this and the lowest I could do was 80, but nothing less than that.

P.S. I tried changing the range and it appears the graph doesn't do more than about 12 gridlines per range.

2 REPLIES 2
ballardw
Super User

Did your LOG show any messages? There are times when you can request more memory for the graph elements than your current settings can actually display.

 

You really should include the entire code of a procedure, and better would be to include the LOG, as the interactions between options of different statements can seriously effect results.

 

A basic request for that many ticks I get:

1    proc sgplot data=sashelp.class;
2      scatter x=weight y=height;
3      xaxis grid values=(1 to 10001 by 50);
4    run;

NOTE: Writing HTML Body file: sashtml.htm
NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           1.38 seconds
      cpu time            0.51 seconds

NOTE: Some of the tick values have been thinned.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.

The thinning is likely at the TICK level, not the grid, because the number of characters to display for 56000, 56050, etc will collide. So a change to the FITPOLICY option of the xaxis looks like a place to start as the default is FITPOLICY=THIN.

Changing to FITPOLICY=ROTATE my log shows:

5    proc sgplot data=sashelp.class;
6      scatter x=weight y=height;
7      xaxis grid values=(1 to 10001 by 50) fitpolicy=rotate;
8    run;

NOTE: PROCEDURE SGPLOT used (Total process time):
      real time           0.37 seconds
      cpu time            0.01 seconds

NOTE: There were 19 observations read from the data set SASHELP.CLASS.

No thinning, the axis labels are rotated diagonally but illegible because there are still too many values to be read at the default size of my graphics area. I suspect unless you are displaying the axis on something approaching 20 or 25 inches that many values the axis text will be non-legible but you can try other axis text options if you want to see them.

ballardw
Super User

If you do actually want some labels with that many grid lines then perhaps use the MINOR, to add tick marks between the labeled tick, MINORCOUNT=<some number> (or MINORINTERVAL if using date/time variable) to provide the number of minor tick marks between the labeled ticks, and  MINORGRID to add the grid lines at the minor ticks as well as the labeled ticks.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 353 views
  • 0 likes
  • 2 in conversation