为了账号安全,请及时绑定邮箱和手机立即绑定

SAS Box Plot

SAS Day 33: Box Plot

Definition:

Box Plot or Whisker plot displays the distribution of 5-number summary of a dataset: minimum, maximum, q1, q3, and Median.

Interpreting quartiles:

The 5-number summary approximately divides the data into 4 sections that each containing 25% of the data.

Explore a little more

If we want to look at the Outliers, we define the points below q1- 1.5(q3-q1) and q3+ 1.5(q3-q1) as outliers.

Note: if we transfer the Q1-Q3 range of a boxplot into a normal distribution, then it maps to the peak of a normal curve (± 0.6745σ).

[caption id=“attachment_2204” align=“alignnone” width=“750”]image

akshayapatra / Pixabay[/caption]

Example:

we will use sashelp.class as an example for box-plot using SGPLOT and TEMPLATE, they both produce the same result!

**Basic Box-Plot **

image

Interpretation:
the median weight of female student is a little lower than 90, 25% of female students’ weight are within 75- 82, 25% are within 105-115 and 50% are between 85-102.

Code:

SPGLOT

proc sgplot data=sashelp.class;
title “Distribution of Weight by Sex”;
vbox weight / category= sex;
run;

TEMPLATE

proc template;
define statgraph ClassBox;
begingraph;
entrytitle “Distribution of Weight by Sex”;
layout overlay;
boxplot y=weight x=sex ;
endlayout;
endgraph;
end;
run;

proc sort data=sashelp.class out=class;
by sex;
run;
proc sgrender data=class template=ClassBox;
run;

Advance Box Plot:

image

Code:

proc univariate data=sashelp.class;

var weight ;
class sex;
ods output quantiles =q;
run;

data q2(rename=(estimate=weight) where=(Quantile ne " “));
set q;
quantile= scan(quantile, 2,”");
run;

proc template;
define statgraph bpp;
begingraph;
entrytitle “Distribution of Weight by Sex” ;
layout overlay;
boxplotparm y=weight x=sex stat=quantile;
endlayout;
endgraph;
end;
run;

proc sgrender data=q2 template=bpp;
run;

with the extra univariate step, we have a summary dataset to look for cross-validate the graph.
we can see indeed the min of female students weight is 50.

image

Reference:

Creating Statistical Graphics in SAS,
*Warren F.Kuhfeld  *

**Happy Practicing!

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消