【SAS NOTES】ods

 1 data mysas.mmsone;
 2     infile 'E:\SAS\mysas\MMS1.txt' dlm='09'x firstobs=2;
 3     input date city $ wangnei wangjian guoji shangxing wangneid wangjiand 
 4             guojid alld allwangnei allwangjian allguoji allall upfeetiao downfeetiao;
 5 run;
 6 proc sort data=mysas.mmsone;
 7     by city;
 8 run;
 9 
10 ods trace on;
11 proc means data=mysas.mmsone;
12     by city;
13     ods select  Means.ByGroup21.Summary;
14 run;
15 ods trace off;

1、文本类变量一定要加上$

2、Ods output deliver system 

使用ods trace on +ods trace off来确定输出内容有哪些。用ods select +输出内容 来选中特定的内容输出。

 1 ods trace on;
 2 proc tabulate data=mysas.mmsone;
 3     class city date;
 4     var wangnei wangjian;
 5     table city all,date,(wangnei wangjian)*max;
 6     ods output Tabulate.Report.Table=mysas.reportmms;
 7     run;
 8 ods trace off;
 9 proc print data=mysas.reportmms;
10 run;

用ods trace确定输出的内容后可以用ods output ***=dataset 来实现将处理结果输出到新数据集。

1 ods html file='E:\SAS\mysas\outputhtml.html';
2 ods noproctitle;
3     proc tabulate data=mysas.mmstwo;
4         class city date;
5         var wangnei wangjian;
6         table city all,date,(wangnei*mean wangjian*min);
7     run;
8 ods html close;

用ods html file +ods noproctitle+ods html close 来将中间圈定的输出用html来展现。

1 ods rtf file='E:\SAS\mysas\outputrtf.rtf';
2 ods noproctitle;
3     proc means data=mysas.mmstwo;
4         class city date;
5         var wangnei wangjian;
6         by city;
7     run;
8 ods rtf close;

类似生成html ods 也可以用来生成rtf格式(即word格式)的文件,区别在于将html 换成rtf

 同样原理,ods可以生成pdf pcl ps格式的文档。

1 ods rtf file='E:\SAS\mysas\outputrtf.rtf';
2 ods noproctitle;
3     proc means data=mysas.mmstwo;
4         class city date;
5         var wangnei wangjian;
6         by city;
7         title color=green 'this' bcolor=navy 'is' height=1cm 'a' justify=center bold 'title.';
8     run;
9 ods rtf close;

对title 和footnotes的字体等控制。

1 ods html file='E:\SAS\mysas\style.html';
2 proc print data=mysas.mmstwo
3     style(data)={background=pink};
4     var city wangnei wangjian date;
5     var wangnei/style(data)={font_weight=bold};
6     id city;
7     run;
8 ods html close;

在proc print 和var 中通过加入style(data)or /style(data)={}来实现对背景或某个变量的单独控制。

1 ods pdf file='E:\SAS\mysas\stylepdf1.pdf';
2 proc tabulate data=mysas.mmstwo
3     style={background=silver};
4     class city/style={background=green};
5     var  wangnei wangjian;
6     table city all,(sum*wangnei*all N*wangjian*all*{style={background=white}});
7 run;
8     ods pdf close;

在proc report和proc tabulate 中同样可以使用style={}来改变输出的样式,注意style在report和tabulate中不同位置的写法。class为 /style table为*style{}

原文地址:https://www.cnblogs.com/colipso/p/2878551.html