Data visualization with SAS programming

Box and whisker plot generation

New User
Posts: 1

Box and whisker plot generation



I am using proc boxplot to generate the box plots that I need.

We have a couple of requirements for the figure we are trying to create:

1)  We need to have the summary statistics such as n, min max, outliers etc. in the box plot in the form of a table.  We have tried
the "insetgroup" option but it is not displaying the "NOUT" "NHIGH" and "NLOW" values which is the count of the outliers.

2) We also need to group the boxplots side by side by treatment.  Currently we are using in the plot statement the following code:

plot aval*avisitn  / boxstyle = schematic vref= 3.5 40.0  haxis = 1 to 19 by 1;

The y-axis values (aval) are result of lab tests and the x-axis values (avisitn) are the visits.  Hence we are plotting the lab values per visit.

We now need to group multiple treatments for each visit side by side.  We tried the following "plot aval*avisitn = trt02p".  This did
not give the desired result.  TRT02P is the treatment variable.

We are currently using SAS 9.4 on the server.  Can you suggest if these 2 situations can be accommodated in proc boxplot or not.

If anyone has an alternative approach then please specify.  I have tried proc sgplot and I am able to get the box plots side by side, however, the inset option is not automatically going to display the summary stats.  They will have to be calculated and manually put.

Since each lab test will be on a separate page i.e. plotting "by paramcd"  where paramcd is the unique lab test code, it will be difficult to code this.


Looking for suggestions.



Posts: 1,097

Re: Box and whisker plot generation

I am no expert on PROC BOXPLOT, so I can not say if it can be done. I recommend using PROC SGPLOT. Have a look at this example and the solution by @Ksharp to get you started


Posts: 1,396

Re: Box and whisker plot generation

Suggest you post a small amount of sample data, for people to play with.  I agree with the suggestion to look into SGPLOT (or even GTL), for the box plot, and see the axistable statement for generating a table of summary statistics below the plot.  SGPLOT is very friendly, lots of examples at Sanjay Matange's blog, e.g.:

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation