Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Graphics
- /
- Box and Whisker Plots with p-value included

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 08-13-2014 09:59 PM
(6854 views)

I am looking for a nice way to represent information on a given study for my classroom. I have two separate groups A and B and want to compare them (hoping that B is statistically significantly better than A). How can I program this? I am very new to this and not sure what to do! I think a box an whisker plot would look nice, but also want the p-value shown on the top comparing the two.

A 2.7

A 0.0

A 3.1

A 4.6

B 6.2

B 5.2

B 3.5

B 3.6

B 5.9

Any help is appreciated! Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The SAS code below takes your data set and reads the A and B into a variable called GROUP and the measures into a variable called VALUE. I then ran the TTEST procedure with plots=box. The output shows the p-values in a table and the boxplot below if that is okay. This is one of the easiest ways I could think of. The SAS output is contained in the attached pdf file. All the best - Randy

data work.compare;

length group $**1**;

input group value;

cards;

A 2.7

A 0.0

A 3.1

A 4.6

B 6.2

B 5.2

B 3.5

B 3.6

B 5.9

;

run;

ods graphics on;

proc **ttest** data=work.compare plots=box;

class group;

var value;

ods graphics off;

"All truths are easy to understand once they are discovered; the point is to discover them." G.G.

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

You will need to run a test that creates p-values. Depending on the version of SAS you are using then you can add that value to a graph using an annotate dataset with your graph procedure.

Also, is that your actual data or do you have more records? Tests for a small sample is displayed are going to much different than for a larger sample. Also when compare (test) are you looking at means or distribution or something else?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The SAS code below takes your data set and reads the A and B into a variable called GROUP and the measures into a variable called VALUE. I then ran the TTEST procedure with plots=box. The output shows the p-values in a table and the boxplot below if that is okay. This is one of the easiest ways I could think of. The SAS output is contained in the attached pdf file. All the best - Randy

data work.compare;

length group $**1**;

input group value;

cards;

A 2.7

A 0.0

A 3.1

A 4.6

B 6.2

B 5.2

B 3.5

B 3.6

B 5.9

;

run;

ods graphics on;

proc **ttest** data=work.compare plots=box;

class group;

var value;

ods graphics off;

"All truths are easy to understand once they are discovered; the point is to discover them." G.G.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Is there anyway on the box-plot that I could include all the data points?

Both your answer (RandyCollica) and (stat@sas) answers are exactly what I needed!! Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Hi,

This can provide the boxplot with p value added on it.

ods graphics on;

ods select boxplot;

proc anova data=have;

class group;

model value=group;

quit;

ods graphics off;

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 25. Read more here about **why** you should contribute and **what is in it** for you!

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.