BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NKormanik
Barite | Level 11

Would someone please steer me in the right direction for creating the following:

 

Grade-Height.png

In the example above, there are four grade levels, and height generally overlaps to a degree.

 

Ideally the plot should show a distribution, clustering toward the center of each grade, and outliers at either end.

 

Thanks very much!

 

Nicholas Kormanik

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

I like draycut's solution because it seems closest to the image that you posted. However, be aware that box plots show a schematic representation of the distribution, and jittering breaks down when you get to thousands of observations. For larger samples, look at comparative histograms, which scale to larger samples.

View solution in original post

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

My goto place for anything graph related is this site:

http://blogs.sas.com/content/graphicallyspeaking/

 

There are thousands of examples there.

PeterClemmensen
Tourmaline | Level 20

Follow this example and use HBOX instead of VBOX in PROC SGPLOT.

 

http://blogs.sas.com/content/graphicallyspeaking/2017/06/16/scatter-mean-value/

 

Plot sample data if you want a code answer 🙂

stat_sas
Ammonite | Level 13

Hi,

 

You can try proc boxplot for this type of analysis. It will compare distribution of height at each grade. Also highlights outliers and skewness.

Rick_SAS
SAS Super FREQ

I like draycut's solution because it seems closest to the image that you posted. However, be aware that box plots show a schematic representation of the distribution, and jittering breaks down when you get to thousands of observations. For larger samples, look at comparative histograms, which scale to larger samples.

NKormanik
Barite | Level 11

Rick, I think the first plot from your article will work well for my purpose.

 

Code:

 

proc univariate data=sas_1.divisions_20905;
  class Rank;
  var i_20905;
  histogram i_20905 / nrows=7 odstitle="i_20905";
  ods select histogram;
run;

 

Two follow-up questions:

 

1. Could we overlay some statistical information within the plot, such as percentile numbers?

 

2. Output plot files need to be appropriately named.  In the case above, "i_20905".

 

Thanks so much for your help.  As well as to the others here.

 

 

NKormanik
Barite | Level 11

The following seems to work out pretty well.  Thanks again for everyones help.

 

ods graphics on / reset=index imagename="20905";

proc univariate data=sas_1.divisions_20905;
class rank (order=data);
var i_20905;
histogram i_20905 / nrows=7 odstitle="20905";
inset nobs max p95 p75 mean p50 p25 p5 min / format=6.1 pos=nw;
ods select histogram;
run;

 

ballardw
Super User

Doesn't show "outliers" but something like this perhaps:

 

data example;
   do grade= 1 to 4;
      do i=1 to 1000;
         height = grade*2 + round(rand('uniform')*36);
         output;
      end;
   end;
run;

proc sgplot data=example;
   density height /group=grade;
run;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 7 replies
  • 1466 views
  • 7 likes
  • 6 in conversation