Graphics Programming

Data visualization using SAS programming, including ODS Graphics and SAS/GRAPH. Charts, plots, maps, and more!
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Manj
Fluorite | Level 6
yes , this works. but wonder why my code which is on the similar lines doesnt work
quickbluefish
Lapis Lazuli | Level 10
Interesting @DanH_sas - it looks like you *did* apply jitter to the ageatstart variable here?
DanH_sas
SAS Super FREQ

No, I did not apply any data jittering here. I think you hit the correct root cause. 

quickbluefish
Lapis Lazuli | Level 10
Only other thing I can think of is that the 'jitter' you're applying is causing some sort of issue. If you remove the jitter, do you get the same problem? When I test this on fake data, I get warnings in the log saying that not all boxes were drawn if I either apply jitter OR if I specify 2 separate y-axes. I suspect SGPLOT might not be capable of this particular combination of things.
Quentin
Super User

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.

 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Rick Wicklin presents Ten Tips for Effective Statistical Graphics (with SAS code) on Wednesday March 26.
Register now at https://www.basug.org/events.
Manj
Fluorite | Level 6

Looks like the jitter created the issue. Thank you so much for pointing this.

Quentin
Super User

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.  

 

 

 

 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Rick Wicklin presents Ten Tips for Effective Statistical Graphics (with SAS code) on Wednesday March 26.
Register now at https://www.basug.org/events.
Manj
Fluorite | Level 6
okay !, but I had done it for line plots like this earlier. May be works different for box plots
Quentin
Super User
I think it all depends on your axis. For series plots the x-axis is typically continuous, so you can do a bit of jittering. But for box plots, the x-axis is categorical. So if you do the jittering and specify values for the x-axis, you would need to specify jittered values on the x axis.

The Boston Area SAS Users Group is hosting free webinars!
Next up: Rick Wicklin presents Ten Tips for Effective Statistical Graphics (with SAS code) on Wednesday March 26.
Register now at https://www.basug.org/events.
Manj
Fluorite | Level 6

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

Manj_0-1739264471080.png

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;

Quentin
Super User

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

 

The Boston Area SAS Users Group is hosting free webinars!
Next up: Rick Wicklin presents Ten Tips for Effective Statistical Graphics (with SAS code) on Wednesday March 26.
Register now at https://www.basug.org/events.
DanH_sas
SAS Super FREQ

What is your goal in setting WHISKERPCT=25? Are you trying to make the whiskers go away?

sas-innovate-white.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Save $200 when you sign up by March 14!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 26 replies
  • 1131 views
  • 9 likes
  • 4 in conversation