I have a series plot with error bars (series + highlow) where I had to add or subtract from the x axis values to separate the points. When I added the xaxis table to the plot, those values are also offset (I do not want this). I introduced a second hidden series plot using an X2 axis with the original values and tied the xaxis table to the X2 axis, but it didn't work. What am I missing?
Current code with the second series plot as described above:
proc sgplot data=stats2 dattrmap=myattrmap ;
where param = "&¶m&i";
highlow x=month low=llim high=ulim / group=eyefl attrid=eyefl
highcap=serif lowcap=serif lineattrs = (thickness = 2) ;
series x = month2 y = mean/lineattrs=(thickness = 0) markerattrs = (size = 0);
series x=month y=mean/LINEATTRS= (THICKNESS= 2 ) group = EYEFL markers markerattrs = (size =7pt) grouporder = data name = 'Key' attrid = eyefl ;
series x = month2 y = mean/ name = 'Key 2' lineattrs = (thickness = 0) markerattrs = (size = 0pt);
yaxis values = (-10 to 10 by 1) grid valueattrs = (size = 7pt) labelattrs = (size = 7pt) label = 'Change from Baseline (dB)';
xaxis values = (0 to 3 by 1) offsetmin = 0.03 offsetmax = 0.03 valueattrs = (size = 7pt) labelattrs = (size = 7pt) label = 'Month';
Keylegend 'Key' /VALUEATTRS=(size=7pt family = 'Courier New') across = 6;
xaxistable n/class = eyefl valueattrs = (size = 7pt) labelattrs = (size = 7pt) labelpos = left x2axis x = month2;
run;
I would say you are missing two data sets and two macro variable values to test your code.
Or as an absolute minimum a resulting graph and a clear description of what you expect. It is very hard to tell exactly which values are "also offset" .
@_Hopper wrote:
1. I cannot give you the data. It is not for the public domain.
Make a dummy data set with non-sensitive values that behaves the same.
I wouldn't even make an attempt without the attribute data set as a lot of stuff can be buried in there.
Not to mention if there are any custom formats involved for your variables and values appearing the attribute set.
@_Hopper wrote:
2. The macro variable is a series of parameters the graph program rotates. Also not needed to solve the issue.
If code includes a WHERE statement must be able to test that. If you provide a single use case then we can drop the where.
I am way too lazy to attempt to create a data set and an attribute data set that may or may not show the same behavior.
Instead of changing the X values to get spacing, what happens if you use GROUPDISPLAY=CLUSTER on the HIGHLOW and SERIES, and CLASSDISPLAY=cluster on the XAXISTABLE? You should be able to leave the axis table assigned to the X axis in that case.
Hope this helps!
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.
Ready to level-up your skills? Choose your own adventure.