Hi
晚上好!
上次给大家简单的share了SAS DDE输出Excel
今天
给大家带来了的是
SAS ODS
Proc Report
输出RTF的实例
在SAS实际编程过程中经常会用到Ods 与report来输出table/listing
尤其是在临床试验的统计编程中(TFL)
(一)
Report过程步前的设置
- ods:设置rtf输出的文件的路径,页眉页脚的控制,以及实现Table的样式(通过Style参数来调用设计好的Template) ods rtf file = "&path&report..rtf" style = &style. startpage=&startpage.;(startpage控制是否从新的一页开始)
- 常用的输出RTF的Option选项: option nobyline nodate nonumber orientation="&orient1" papersize=letter ;(orientation控制纸张方向:LANDSCAPE、PORTRAIT)
- 设置页眉页脚的页码显示:
ods escapechar='^';
title1 justify = right 'Page ^{thispage} of ^{lastpage}';
(二)
Report过程
废话不多说直接sashelp.class中的数据集做实例
ods rtf exclude none;
proc report data=final nowd headskip headline split='|' missing nocenter;
column Name Sex Age Height Weight;
define Name / display "Name | of Student" style(header)=[just=center] style(column)=[just=center cellwidth=10% asis=on] flow;
define Sex / display "Sex" style(header)=[just=center] style(column)=[cellwidth=10% just=center asis=on] flow;
define Age / display "Age" style(header)=[just=center] style(column)=[cellwidth=20% just=center asis=on] flow;
define Height / display "Height" style(header)=[just=center] style(column)=[cellwidth=20% just=center asis=on] flow;
define Weight / display "Weight" style(header)=[just=center] style(column)=[cellwidth=20% just=center asis=on] flow;
compute after / style = [just=left font_weight=medium font_size=9pt nobreakspace=off
bordertopcolor=black bordertopwidth=.5pt];
line "comments: the dataset from sashelp";
endcomp;
run;
column :申明需要在report中出现的变量
define : 设置变量的label 那一列的样式等等 以及所占单元格的大小.....很多都是在define中设置的
compute : 插入一些计算啊啥的...
(三)
结束
ods rtf close;
ods listing;
result
另附Template 表格的控制
proc template;
define style tab_3;
parent = styles.rtf;
replace fonts / 'TitleFont2' = ("Times New Roman", 8pt, Medium)
'TitleFont' = ("Times New Roman", 8pt, Medium)
'DocFont' = ("Times New Roman", 8pt, Medium)
'StrongFont' = ("Times New Roman", 8pt, Medium)
'EmphasisFont' = ("Times New Roman", 8pt, Italic)
'FixedFont' = ("Times New Roman", 8pt, Medium)
'BatchFixedFont' = ("Times New Roman", 8pt, Medium)
'FixedStrongFont' = ("Times New Roman", 8pt, Medium)
'FixedEmphasisFont' = ("Times New Roman", 8pt, Italic)
'HeadingFont' = ("Times New Roman", 8pt, Medium);
replace Header from HeadersandFooters / font = ("Times New Roman", 8pt, Medium)
background = white
protectspecialchars = off;
replace cell from output / font = ("Times New Roman", 8pt, Medium)
style body from body / bottommargin = 1.0 in
topmargin = 1.0 in
rightmargin = 1.0 in
leftmargin = 1.0 in;
style Table from Output /
cellpadding = 0
cellspacing = 0
outputwidth = 100%
frame = HSIDES
OUTPUTHEIGHT=1;
end;
run;