BookmarkSubscribeRSS Feed
Fluorite | Level 6

The highest and lowest y-axis ticks on my graph are not meeting the axis line properly. See my yaxis code and pictures below. I am using SGPLOT.

yaxis label='Percent of all admissions aged 12 years and older' VALUES = (0 TO 50 BY 10) tickvalueformat=data labelattrs=(family=Arial size=8) offsetmax=0 offsetmin=0 
thresholdmin=1 thresholdmax=1 valueattrs=(family=Arial size=8);


Super User

It is a good idea to share some data that will recreate the issue and show the entire procedure code.

Instructions here: will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

Provide all ODS graphics options that are also in effect when the program is run.


Since this is an appearance issue which ODS destination are you sending the output to?

In some cases some resolution of monitor/graphic file type and DPI settings can cause things not to appear to align at some viewing resolutions.

Fluorite | Level 6

The output destination is PDF. See my full code below. I've also attached my data. 

proc template;
define style Custom;
parent = Styles.default; 
class graphaxislines/color=black width=0.75pt;
class graphbackground/color=white;

PROC IMPORT OUT= WORK.prim_sub_use DATAFILE= "E:\SAS figures\Primary substance use data"
            DBMS=xlsx REPLACE;

data prim_sub_use;
set prim_sub_use; 
Alcohol	='^_^_Alcohol^_'
Opiates	='^_^_Opiates^_'
Cocaine	='^_^_Cocaine^_'

ods _all_ close;
options nonumber nodate orientation=landscape papersize=letter nocenter
leftmargin=.5in rightmargin=.5in topmargin=.5in bottommargin=.5in;
ods pdf file="E:/SAS figures/fig1_pdf_new.pdf" dpi=300 notoc;
ods pdf style=Custom;
ods layout start style={bordercolor=white borderstyle=solid borderwidth=1pt backgroundcolor=white} description='Primary substance use at admission, 2007-2017';
ods noptitle;
ods region x=0in y=0in width=6.5in style=[borderwidth=1 bordercolor=white backgroundcolor=white];
ods graphics on/ reset=all border=off noborder width=6.5in scale=on;

proc sgplot data=prim_sub_use noborder nowall;
series x=Year y=Alcohol/markers markerattrs=(symbol=CircleFilled color='#0060A9' size=12) lineattrs=(color='#0060A9' thickness=1.5pt);
series x=Year y=Opiates/markers markerattrs=(symbol=TriangleDownFilled size=12 color='#ed1c24') lineattrs=(color='#ed1c24' thickness=1.5pt pattern=solid);
series x=Year y=Cocaine/markers markerattrs=(symbol=SquareFilled color='#ffc222' size=12) lineattrs=(color='#ffc222' thickness=1.5pt pattern=solid);
series x=Year y=Marijuana/markers markerattrs=(symbol=DiamondFilled color='#64c069' size=12) lineattrs=(color='#64c069' thickness=1.5pt pattern=solid) legendlabel="Marijuana/hashish";
series x=Year y=Methamphetamine_amphetamines/markers markerattrs=(symbol=TriangleFilled size=12 color='#00a2e5') lineattrs=(color='#00a2e5' thickness=1.5pt pattern=solid);
yaxis label='Percent of all admissions aged 12 years and older' VALUES = (0 TO 50 BY 10) tickvalueformat=data labelattrs=(family=Arial size=8) offsetmax=0 offsetmin=0 
thresholdmin=1 thresholdmax=1 valueattrs=(family=Arial size=8);
xaxis label='Admission Year' VALUES = (2007 TO 2017 BY 1) display=(nolabel noticks) valueattrs=(family=Arial size=8);
keylegend/noborder linelength=30 fillaspect=golden valueattrs=(family=Arial size=8);

ods graphics off;
ods layout end;
ods pdf close;
ods _ALL_ CLOSE;
Opal | Level 21

It could be that antialiassing has been turned off. This happens when there are more than 4000 elements to draw in a plot. You can ask for a higher limit in the ODS GRAPHICS statement with option



Fluorite | Level 6
Adding this option does not seem to make any difference.
Barite | Level 11

Either suppress the tickmarks or use the accepted solution (inside ticks), both shown here


If you do keep the status quo, I don't believe anybody will even notice the tick lines not matching at the joint




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
  • 4 in conversation