图形种类
w3cschool上说明了5种
直方图
PROC UNIVARIATE /*这个procedure可以得到:矩、位置和可变形的基本测度、位置检验、分位数、极值观测*/
DATA= SASHELP.CARS noprint; /*不输出*/
WHERE MAKE = 'Audi'; /*选择audi*/
VAR HORSEPOWER; /*和HISTOGRAM HORSEPOWER等价*/
HISTOGRAM
/ normal( /* 拟合一个正态曲线 */
mu = est /* 参数是est */
sigma= est
color = blue
w = 2.5
)
barlabel = percent /* y label */
midpoints = 70 to 550 by 50 /* 确定xlim是70-550步长50 */
kernel; /*添加一条kernel线,实际拟合?*/
RUN;
简单条形图
PROC SQL; /*用sql语句新建一个表默认在work下面叫cars1*/
CREATE TABLE CARS1 AS
SELECT MAKE,MODEL,TYPE,INVOICE,HORSEPOWER,LENGTH,WEIGHT
FROM
SASHELP.CARS
WHERE MAKE IN ('Audi','BMW')
;
RUN;
PROC SGPLOT
DATA = WORK.CARS1;
VBAR LENGTH; /*确定类型是vertical bar,名字叫length*/
TITLE ' LENGTH OF CARS ';
RUN;
QUIT; /*在sql结束的时候要quit*/
堆叠条形图
proc SGPLOT data=work.cars1;
vbar length /group = type ; /*分组是按type,这里大小写不区分*/
title 'Lengths of Cars by Types';
run;
quit;