SAS进阶《深入分析SAS》之数据汇总和展现
1. 通过Print过程制作报表
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
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过程制作图行
分组变量
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输出
proc sort data=sashelp.prdsale out=work.prdsale;
by country;
run;
ods html path="C:\Users\LEI\Desktop\data"
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;
总结:SAS对数据的汇总和表现两种方式:一种是列表,一种是图行。通过print和tabulate过程制作各种报表和汇总报表;GPLOT过程和GCHART过制作散点图、连线图、气泡图、柱状图等多种图行;ODS输出传送系统,包括如何选择或挑剔输出对象,创建多种格式的输出文件。
时间: 2024-10-04 19:44:08