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 plots on same axis

Options

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

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

Posted 10-09-2017 10:15 PM
(1332 views)

Hello I am given data such as

state 1985 1996 2002

1 73 45 57

2 82 36 48

3 91 29 35

4 74 10 49

etc.

I can create box plots of 1985, 1996 and 2002 seperately.

I use proc sgplot data = mydata;

vbox 1985;

run;

and I do that for the other years as well, I am attempting to get box plots for all 3 years in the same axis or the same graph.

I have tried proc sgpanel as well as proc box plot with no luck.

I am not sure if I need to perhaps combine the 3 variables into 1 category or group and then do a paneled box plot.

Help would be greatly appreciated.

5 REPLIES 5

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

Transpose your data so you can specify the CATEGORY=YEAR.

Post what your code looks like if you're having issues.

Here's an example that's broader than yours:

http://support.sas.com/rnd/datavisualization/yourGraphs/analyticalQuick/vbox/#s1=1

The SASHELP.CARS data set is available on almost all SAS installations.

@Steelz91 wrote:

Hello I am given data such as

state 1985 1996 2002

1 73 45 57

2 82 36 48

3 91 29 35

4 74 10 49

etc.

I can create box plots of 1985, 1996 and 2002 seperately.

I use proc sgplot data = mydata;

vbox 1985;

run;

and I do that for the other years as well, I am attempting to get box plots for all 3 years in the same axis or the same graph.

I have tried proc sgpanel as well as proc box plot with no luck.

I am not sure if I need to perhaps combine the 3 variables into 1 category or group and then do a paneled box plot.

Help would be greatly appreciated.

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

@Reeza wrote:

Transpose your data so you can specify the CATEGORY=YEAR.

Post what your code looks like if you're having issues.

Here's an example that's broader than yours:

http://support.sas.com/rnd/datavisualization/yourGraphs/analyticalQuick/vbox/#s1=1

The SASHELP.CARS data set is available on almost all SAS installations.

@Steelz91 wrote:Hello I am given data such as

state 1985 1996 2002

1 73 45 57

2 82 36 48

3 91 29 35

4 74 10 49

etc.

I can create box plots of 1985, 1996 and 2002 seperately.

I use proc sgplot data = mydata;

vbox 1985;

run;

and I do that for the other years as well, I am attempting to get box plots for all 3 years in the same axis or the same graph.

I have tried proc sgpanel as well as proc box plot with no luck.

I am not sure if I need to perhaps combine the 3 variables into 1 category or group and then do a paneled box plot.

Help would be greatly appreciated.

My current code looks like this

proc import datafile="/folders/myfolders/sasuser.v94/ex3-10.xlsx"

out=mydata dbms=xlsx replace;

run;

title "Box Plot";

proc sgpanel data = mydata;

panelby _1985 _1996 _2002;

vbox year;

*I put year because thats how I think I would get the 3 seperate boxplots but variable is not valid since I cannot get the three columns to be taken as year;

run;

I have also included the dataset that I was given

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

Transpose your data so you can specify the CATEGORY=YEAR.

You can use PROC TRANSPOSE to transform your data.

You don't need SGPANEL, unless you want it panelled. I'm unsure if you're looking for a single graph with three boxes or something else now.

@Steelz91 wrote:

*I put year because thats how I think I would get the 3 seperate boxplots but variable is not valid since I cannot get the three columns to be taken as year;

I think you're not understanding how the PANELBY is created, but I may also not be understanding what you want. Since this is a graph question, I'll move it to the graph forum. The SAS graph staff is great at answering questions.

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

@Reeza wrote:Transpose your data so you can specify the CATEGORY=YEAR.

You can use PROC TRANSPOSE to transform your data.

You don't need SGPANEL, unless you want it panelled. I'm unsure if you're looking for a single graph with three boxes or something else now.

@Steelz91 wrote:*I put year because thats how I think I would get the 3 seperate boxplots but variable is not valid since I cannot get the three columns to be taken as year;

I think you're not understanding how the PANELBY is created, but I may also not be understanding what you want. Since this is a graph question, I'll move it to the graph forum. The SAS graph staff is great at answering questions.

Okay thank you, yeah I want it all on a single graph. I kept googling how to do it and I kept getting the Panelby syntax popping up so I figured maybe they were using that and combining the graph.

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

Check the link I included in my first post. It's probably almost exactly what you want.

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

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.