BookmarkSubscribeRSS Feed
phuzface
Fluorite | Level 6

I have a data set involving a different salaries for different positions at a bunch of different companies.  The different companies are the rows and the different positions (13 total) are the columns.  For the life of me, I cannot figure out how to set up side-by-side box plots for each of the different positions (in the columns).  I actually don't need all thirteen in one graphic, I'd be happy to have just four of them side-by-side. 

 

I've tried variations of the following code:

 

proc boxplot data=SalaryByPosition;
PLOT (AVE_SAL_FULL AVE_SAL_ASSOC AVE_SAL_ASSIST AVE_SAL_ALL)*NAME;
run;

 

"NAME" is just the column header for the names of the companies (there are over a thousand)

 

The error I get mentions not having enough "panels."

 

Any help with this would be appreciated!

1 REPLY 1
ballardw
Super User

It may help to provide a small example data set with 3 or 4 fake companies and a number of values for the other variables similar to your data so we can make some charts and see which comes close to what you want.

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

Your example code would have attempted to create over 1000 plots (one per name) and is the likely problem of not having enough "panels".

 

One approach may require restructuring your data. See if this comes anywhere close to what you might want.

data junk;
   input name $ position $ value ;
datalines;
a  SAL_FULL 50000
b  SAL_FULL 52000
c  SAL_FULL 63000
d  SAL_FULL 57000
e  SAL_FULL 77700
f  SAL_FULL 80000
a  SAL_ASC  44000
b  SAL_ASC  48000
c  SAL_ASC  49000
d  SAL_ASC  55000
e  SAL_ASC  67700
f  SAL_ASC  60000
;
run;

proc sgplot data=junk;
   hbox value/ category=position;
run;

Note that Proc BOXPLOT is pretty old and new enhancements are mostly going to proc SGPLOT/SGPANEL.

 

 

ODS GRAPHICS statement would be using to adjust the size of the graphic area and 13 positions, as above, could be quite easy to fit in a single display.

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
  • 1 reply
  • 2908 views
  • 0 likes
  • 2 in conversation