SAS进阶《深入分析SAS》之数据汇总和展现
1. 通过Print过程制作报表
代码语言:javascript复制proc print <data=数据集>;
run;
选项:
obs=修改观测序号列标签
noobs不显示观测序列号
id语句在输出中取代观测序列
var选择输出的变量
where语句选择输出的观测
总结如下:
proc print data=数据集<选项>;
id 变量1<变量2...>;
var 变量1<变量2...>;
where 表达式;
sum 变量1 <变量2...>;
where 表达式;
sum 变量1<变量2...>;
sumby 变量1<变量2...>;
run;
2. tabulate
代码语言:javascript复制proc tabulate data=Saslib.Sales2;
title1 'Sales in North America';
title2 'TOtal Transactions';
/*
*class为分类变量
*/
class Emp_ID Dept;
var Sales;
table Dept*Emp_ID,Sales;
run;
3. 通过GPLOT过程制作图行
分组变量
代码语言:javascript复制 axis1 order=(18900 to 18960 by 5);
axis2 order=(9000 to 20000 by 1000);
minor=(color=blue height=0.25 number=1);
symbol value=# cv=red
interpol=join ci=blue;
proc gplot data = Saslib.Sales;
title f = 'Albany Amt' c = blue h = 3 u = 2 'Yearly Amount in North America';
footnote j = r 'Optimization Solution Co.Ltd';
plot Sales*Date=Emp_ID/haxis=axis1 vaxis=axis2;
run;
quit;
goptions reset=all;
4. 增强型HTLM输出
代码语言:javascript复制 proc sort data=sashelp.prdsale out=work.prdsale;
by country;
run;
ods html path="C:UsersLEIDesktopdata"
body='prdsalebody.html'
frame='prdsaleframe.html'
contents='prdsalecontents.html';
proc tabulate data=work.prdsale;
class region division prodtype;
var actual;keyword all sum;
keylabel all='Total';
table (region all)*(division all),
(prodtype all)*(actual*f=dollar10.) / misstext=[label='Missing']
box=[label='Region by Division and Type'];
run;
ods select ExtremeObs Quantiles Moments;
proc univariate data=work.prdsale;
by Country;
var actual;
run;
ods html close;