下面是proc univariate
而非proc capability
,我没有获得SAS/QC测试,但用户指南显示直方图语句很相似的语法。希望你能翻译回来。
看起来您由于输出系统而出现颜色问题。您的图表可能通过ODS提供,在这种情况下,cfill选项不适用(请参阅here而不是传统图形标签)。
要更改ODS输出的柱状图的颜色,您可以使用proc template
:
proc template;
define style styles.testStyle;
parent = styles.htmlblue;
style GraphDataDefault/
color = green;
end;
run;
ods listing style = styles.testStyle;
proc univariate data = sashelp.cars;
histogram mpg_city;
run;
一个例子解释这个可以发现here。
或者您可以使用proc sgplot
创建具有颜色的更多控制的柱状图如下:
proc sgplot data = sashelp.cars;
histogram mpg_city/fillattrs = (color = red);
run;
至于你截断直方图的问题。忽略极端值并不是很有意义,因为它会给你一个错误的分布图像,这有点失败了直方图的目的。这就是说,你可以达到你所要求的与一个黑客位:
data tempData;
set sashelp.cars;
tempClass = 1;
run;
proc univariate data = tempData noprint;
class tempClass;
histogram mpg_city/maxnbin = 5 endpoints = 0 to 25 by 5;
run;
在一个虚拟的类tempClass
上面创建,然后使用class
声明要求比较直方图。 maxnbins
将限制仅在比较直方图中显示的垃圾箱数量。
您的其他选择是在创建直方图之前排除(或限制)您的极值点,但这会导致略微错误的频率计数/百分比/酒吧高度。
data tempData;
set sashelp.cars;
mpg_city = min(mpg_city, 20);
run;
proc univariate data = tempData noprint;
histogram mpg_city/endpoints = 0 to 25 by 5;
run;
这是一个可行的方法,以原来的问题(未经测试,因为没有SAS/QC或数据):
proc capability data = HW2 noprint;
histogram Mvisits/
midpoints = 0 to 300000 by 10000
noplot
outhistogram = histData;
run;
proc sgplot data = histData;
vbar _MIDPT_/
response = _OBSPCT_
fillattrs = (color = blue);
where _MIDPT_ <= 100000;
run;
你有非常大的数值,这使得两条曲线无用的,如果你有兴趣的可视化数据在典型值附近的分布(例如,在直方图的情况下为0-3000)。无论如何,这个问题是无关紧要的,因为它是关于SAS编程的。 – chl 2014-09-20 19:02:00
[绘制SAS中的直方图]的可能的副本(http://stackoverflow.com/questions/25944250/drawing-histogram-in-sas) – 2014-09-20 19:12:29