BookmarkSubscribeRSS Feed
sgilani
Calcite | Level 5

Hi,

 

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.

 

Thanks.

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

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

 

https://communities.sas.com/t5/Base-SAS-Programming/proc-SGPLOT-vbox-summary-statistics-like-proc-bo...

 

Quentin
Super User

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.:

 

https://blogs.sas.com/content/graphicallyspeaking/2015/12/23/box-plot-with-stat-table-and-markers/

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1045 views
  • 0 likes
  • 3 in conversation