No, I did not apply any data jittering here. I think you hit the correct root cause.
If you comment out the xaxis statement, do you get boxes?
If you comment out yaxis statement?
I wonder if the values you entered on the xaxis statement are not the actual values in your dataset. Or if your values are outside the yaxis.
One thing I don't like about SGPLOT vs the much older traditional GPLOT is that SGPLOT does not throw a NOTE when you have data outside of your axes. It's possible all your data is outside the axes.
You didn't show your MYATTR dataset. Could it be everything is set to transparent?
I would suggest start with a working plot that is simple, maybe:
proc sgplot data=ip ;
vbox aval1 / category=vis group=param1 nomean nooutliers whiskerpct=25
connect=median lineattrs=( pattern=1) attrid=param1;
run;
And then add back more of your real code incrementally, until the boxes disappear.
Looks like the jitter created the issue. Thank you so much for pointing this.
In the DATA step you manually introduced jitter in the values of VIS.
In the XAXIS statement you specified the values to be plotted:
values=(0,1,2,3,4,6,8,10,12,16,20,24,28,32,36,40,44,48,52 )
My guess is after you jitter the data, those values don't appear in your data.
Thank you both, I made the plot as below, however i face an issue with inverted whisker line on some of the boxes. why is this appearing and how to remove this? Thanks
proc sgplot data=ip dattrmap=myattr;
vbox aval1 / category=avisit group=param lineattrs=( pattern=1) nomean whiskerpct=25 nooutliers connect=median nofill whiskerattrs=(thickness=0.00001) attrid=param1 name='v1';
vbox aval2 / category=avisit group=param y2axis nomean whiskerpct=25 nooutliers connect=median nofill attrid=param1 name='v2';
yaxis label='Normalized AAA value' values=(0 to 1.3 by 0.1) valueattrs=(size=8);
y2axis label='The reciprocal antibody titer' TYPE=LOG LOGBASE=2 valueattrs=(size=8) values=(6.25,12.5,25,50,100,200,400,800,1600,3200,6400,12800,25600,51200,102400,204800,1638400,3276800 ) valuesformat=best. ;
xaxis label='Analysis visit' DISCRETEORDER=DATA ;*values=(0,1,2,3,4,6,8,10,12,16,20,24,28,32,36,40,44,48,52 ) valuesdisplay=('Baseline' 'Week 1' 'Week 2' 'Week 3' 'Week 4' 'Week 6' 'Week 8' 'Week 10' 'Week 12' 'Week 16' 'Week 20' 'Week 24' 'Week 28' 'Week 32' 'Week 36' 'Week 40' 'Week 44' 'Week 48' 'Week 52' ) fitpolicy=rotate valuesrotate=diagonal valueattrs=(size=8);
keylegend "v1" / title="" position=bottom location =outside down=1 valueattrs=(size=8) noborder;
run;
That's odd. If your goal is to get rid of the whiskers, you could try:
whiskerattrs=(thickness=0)
Suggestion taken from:
https://communities.sas.com/t5/Graphics-Programming/Creating-a-boxplot-without-whiskers/td-p/248745
What is your goal in setting WHISKERPCT=25? Are you trying to make the whiskers go away?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.