Data visualization with SAS programming

See distributions of student height by grade level

Accepted Solution Solved
Reply
Regular Contributor
Posts: 223
Accepted Solution

See distributions of student height by grade level

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

 

 

 


Accepted Solutions
Solution
‎09-15-2017 05:35 AM
SAS Super FREQ
Posts: 3,623

Re: See distributions of student height by grade level

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


All Replies
Super User
Super User
Posts: 7,711

Re: See distributions of student height by grade level

My goto place for anything graph related is this site:

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

 

There are thousands of examples there.

PROC Star
Posts: 653

Re: See distributions of student height by grade level

[ Edited ]

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 Smiley Happy

Trusted Advisor
Posts: 1,228

Re: See distributions of student height by grade level

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.

Solution
‎09-15-2017 05:35 AM
SAS Super FREQ
Posts: 3,623

Re: See distributions of student height by grade level

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.

Regular Contributor
Posts: 223

Re: See distributions of student height by grade level

[ Edited ]

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.

 

 

Regular Contributor
Posts: 223

Re: See distributions of student height by grade level

[ Edited ]

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;

 

Super User
Posts: 11,118

Re: See distributions of student height by grade level

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 217 views
  • 7 likes
  • 6 in conversation