[英]Boxplot in SAS using proc gchart
First question, is it possible to produce a boxplot using proc gchart in SAS? 第一个问题,是否可以在SAS中使用proc gchart生成箱线图?
If it is possible, please give me a brief idea. 如果可以的话,请给我一个简短的想法。
Or else, on the topic of using proc boxplot. 否则,以使用proc boxplot为主题。 Suppose I have a dataset that has three variables ID score year; 假设我有一个数据集,其中包含三个变量ID得分年份; something like, 就像是,
data aaa;
input id score year;
datalines;
1 50 2008
1 40 2007
2 30 2008
2 20 2007
;
run;
I want to produce a boxplot showing for each ID in each year. 我想制作一个箱形图,显示每年的每个ID。 (So in this case, 4 boxplots in a single plot) How can i achieve this? (因此,在这种情况下,在一个图中有4个箱型图)如何实现?
I have tried using 我尝试使用
proc boxplot data=aaa;
plot score*ID;
by year;
run;
However, this is not working as we can see year is not sorted by order. 但是,这不起作用,因为我们可以看到年份不是按顺序排序的。 Is there a way to get other this? 有办法得到其他吗?
You need to sort your input dataset first. 您需要首先对输入数据集进行排序。 Run this 运行这个
proc sort data = aaa;
by year;
run;
and then your proc boxplot should work as written. 然后您的proc箱图应按书面形式工作。
This is quite easy to do with sgplot
, which is part of the newer ODS Graphics
suite which is available in base SAS. sgplot
很容易做到这一点,它是基础SAS中提供的较新的ODS Graphics
套件的一部分。
proc sgplot data=sashelp.cars;
vbox mpg_city/category=type group=origin grouporder=ascending;
run;
You would use category=id
and group=year
in your example data - you get one separate tick on the x axis for each category
and then you get a separate bar clustered together for each group
. 您将在示例数据中使用category=id
和group=year
-在x轴上为每个category
单独获得一个刻度,然后为每个group
获得一个单独的条形聚类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.