一、Proc report介绍

ODS样式是控制SAS输出表和图的整体外观,可以指定图形元素的颜色、字体、线条样式、符号标记和其他属性。

ODS样式有:ODS HTML、ODS PDF、ODS TRF等。

ODS RTF可以通过Proc print、Proc tabulate、Proc report定义输出,下面主要介绍Proc report过程。

Proc report可以定义SAS数据集中变量输出的格式,以及输出样式等。

二、Proc report语法

PROC REPORT DATA=dataset options;columns var_1,...,var_n;define var_1;define var_2;...;define var_n;COMPUTE blocksBREAK ...;RBREAK ...;
run;

三、简单报表:各样式的定义

1、简单输出:定义变量的输出格式

ods rtf file="D:\sas\example1.rtf";
proc report data=sashelp.class headline headskip;column name sex age height weight;define name/display width=12 '姓名';    /*定义name变量的属性width=12定义的是长度????????‘姓名’定义的是输出到表格的lable,若不定义则为数据集中默认的lable*/define sex/display;define age/display format=8. width=10;  /*format=8. 定义age的输出格式是数值型并非整形*/define height/display format=6.2 width=10;define weight/display format=6.2 width=10;
run;
ods rtf close;

2、Title定义

使用style(report)定义的是表格的标题

用Title和Title1等参数定义的是页眉中的标题

ods rtf file="D:\sas\example2.rtf";
proc report data=sashelp.class headline headskipstyle(report)=[pretext="简单报表" just=center font_size=12pt font_face="宋体" font_weight=bold];       /*定义是表格的标题*/Title1 "简单报表";                       /*定义是页眉中的标题*/column name sex age height weight;define name/display width=12 '姓名';    define sex/display;define age/display format=8. width=10;  define height/display format=6.2 width=10;define weight/display format=6.2 width=10;
run;
ods rtf close;

3、去掉SAS自带的元素输出以及定义纸张方向

orientation=landscape定义页面的输出方向,landscape:横向,portrait:纵向

通过OPTIONS去掉了SAS系统输出的日期,页码。

title;                                    /*清空页眉中的title*/
options nodate nonumber orientation=landscape missing="";
ods rtf file="D:\sas\example3.rtf";
proc report data=sashelp.class headline headskipstyle(report)=[pretext="简单报表" just=center font_size=12pt font_face="宋体" font_weight=bold];       /*定义是表格的标题*/column name sex age height weight;define name/display width=12 '姓名';    define sex/display;define age/display format=8. width=10;  define height/display format=6.2 width=10;define weight/display format=6.2 width=10;
run;
ods rtf close;

四、三线表输出

1、SAS自带的三线表输出
打印结果中红色箭头部分,是什么原因我不记得了,请路过的小伙伴儿指导以下~多谢多谢!

title;                                                 /*清空页眉中的title*/
options nodate nonumber orientation=portrait missing="";
ods rtf file="F:\sas\example4.rtf" style=Journal;      /*journal是SAS本身自带的格式输出*/
proc report data=sashelp.class headline headskip nowdstyle(report)=[pretext=%str("三线表输出")just=center font_size=10pt font_face="Roman" font_weight=bold];column name sex age height weight;define name/display width=12 '姓名';    define sex/display;define age/display format=8. width=10;  define height/display format=6.2 width=10;define weight/display format=6.2 width=10;
run;
ods rtf close;

2、自定义三线表的输出样式(一)
使用自定义的三线表输出样式

Proc template;
define style journalTest;
parent = styles.rtf;style table /just=center        /*居中对齐*/vjust=top          /*位置定义*/cellspacing=0      /*单元格间距*/cellpadding=2      /*单元格边距*/frame=hsides       /*框架类型*/rules=groups;end;
run;
title;
options nodate nonumber orientation=portrait missing="";
ods rtf file="F:\sas\example5.rtf" style=JournalTest; /*JournalTest是SAS本身自带的格式输出*/
proc report data=sashelp.class headline headskip nowdstyle(report)=[pretext=%str("三线表输出")just=center font_size=10pt font_face="Roman" font_weight=bold];column name sex age height weight;define name/display width=12 '姓名';    define sex/display;define age/display format=8. width=10;  define height/display format=6.2 width=10;define weight/display format=6.2 width=10;
run;
ods rtf close;

3、自定义三线表的输出样式(二)

Proc template;
define style journalTest;
parent = styles.rtf;class fonts /"DocFont"      = ("Times New Roman", 10pt)  /*单元格*/"EmphasisFont" = ("Times New Roman", 10pt, Bold)  /*线条*/"HeadingFont"  = ("Times New Roman", 10pt, Bold);  /*表头*/class header /background = whitejust=center;style table /just=center        /*居中对齐*/vjust=top          /*位置定义*/cellspacing=0      /*单元格间距*/cellpadding=2      /*单元格边距*/frame=hsides       /*框架类型*/rules=groupsoutputwidth = 80%;style Cell /just = centerfont_face="Times New Roman"font_size=10pt;end;
run;

五、定义表格的脚注

Proc template;
define style journalTest;
parent = styles.rtf;class fonts /"DocFont"      = ("Times New Roman", 10pt)  /*单元格*/"EmphasisFont" = ("Times New Roman", 10pt, Bold)  /*线条*/"HeadingFont"  = ("Times New Roman", 10pt, Bold);  /*表头*/class header /background = whitejust=center;style table /just=center        /*居中对齐*/vjust=top          /*位置定义*/cellspacing=0      /*单元格间距*/cellpadding=2      /*单元格边距*/frame=hsides       /*框架类型*/rules=groupsoutputwidth = 80%;style Cell /just = centerfont_face="Times New Roman"font_size=10pt;class systemfooter /font_size=10ptjust = lefttextindent=1.4in;end;
run;ods escapechar="^";
title;
footnote;
options nodate nonumber orientation=portrait missing=" ";
ods rtf file="F:\sas\example7.rtf" style=journalTest; /*journalTest是SAS本身自带的格式输出*/
proc report data=sashelp.class headline headskip nowdstyle(report)=[pretext=%str("三线表输出")just=center font_size=10pt font_face="Roman" font_weight=bold];column name sex age height weight;define name/display width=12 '姓名';    define sex/display;define age/display format=8. width=10;  define height/display format=6.2 width=10;define weight/display format=6.2 width=10;
run;
ods rtf text="^S={outputwidth=100% just=l} 注:脚注的定义 ";
ods rtf close;

六、对某一行添加横线

ods escapechar="^";
title;
footnote;
options nodate nonumber orientation=portrait missing=" ";
ods rtf file="D:\sas\example7.rtf" style=journalTest; /*journalTest是SAS本身自带的格式输出*/
proc report data=sashelp.class headline headskip nowdstyle(report)=[pretext=%str("三线表输出")just=center font_size=10pt font_face="Roman" font_weight=bold];column name sex age height weight;define name/display width=12 '姓名';    define sex/display;define age/display format=8. width=10;  define height/display format=6.2 width=10;define weight/display format=6.2 width=10;compute name;if name="简" thencall define ( _row_,'style','style=[bordertopcolor=black bordertopwidth=100%]');endcomp;
run;
ods rtf text="^S={outputwidth=100% just=l} 注:脚注的定义 ";
ods rtf close;

七、对某个单元格进行颜色标记

ods escapechar="^";
title;
footnote;
options nodate nonumber orientation=portrait missing=" ";
ods rtf file="D:\sas\example7.rtf" style=journalTest; /*journalTest是SAS本身自带的格式输出*/
proc report data=sashelp.class headline headskip nowdstyle(report)=[pretext=%str("三线表输出")just=center font_size=10pt font_face="Roman" font_weight=bold];column name sex age height weight;define name/display width=12 '姓名';    define sex/display;define age/display format=8. width=10;  define height/display format=6.2 width=10;define weight/display format=6.2 width=10;compute age;if age=16 thencall define ('age','style','style=[color=red]');endcomp;
run;
ods rtf text="^S={outputwidth=100% just=l} 注:脚注的定义 ";
ods rtf close;

八、添加页码

ods escapechar="^";
title;
footnote justify=right '第^{thispage}页/共^{lastpage}页';
options nodate nonumber orientation=portrait missing=" ";
ods rtf file="D:\sas\example7.rtf" style=JournalTest; /*JournalTest是SAS本身自带的格式输出*/
proc report data=sashelp.class headline headskip nowdstyle(report)=[pretext=%str("三线表输出")just=center font_size=10pt font_face="Roman" font_weight=bold];column name sex age height weight;define name/display width=12 '姓名';    define sex/display;define age/display format=8. width=10;  define height/display format=6.2 width=10;define weight/display format=6.2 width=10;
run;
ods rtf text="^S={outputwidth=100% just=l} 注:脚注的定义 ";
ods rtf close;

九、表格输出

data test;input group $ sex $ class $ count;cards;
A 男 Y 12
A 女 N 10
A 女 Y 11
A 男 N 18
B 女 Y 13
B 女 N 14
B 男 N 17
B 男 Y 11
;
run;ods escapechar="^";
title;
footnote;
options nodate nonumber orientation=portrait missing=" ";
ods rtf file="D:\sas\example11.rtf" style=JournalTest; /*JournalTest是SAS本身自带的格式输出*/
proc report data=test headline headskip nowdstyle(report)=[pretext=%str("各类表格输出1")just=center font_size=10pt font_face="Roman" font_weight=bold];column group sex class count;define group/order width=12 '分组';define sex/order '性别';define class/order width=10 '是否回答';define count/format=6.2 width=10 '频数';compute before group;line '';endcomp;
run;
ods rtf close;

十、表格输出2

data test;input class1 $ class2 $ group1 $ group2 $;cards;
性别 男 5(33.3%) 6(46.2%)
性别 女 10(66.7%) 7(53.8%)
年龄 n 15 13
年龄 Mean 50.7 54.9
年龄 Median 50.0 56.0
年龄 STD 9.20 7.22
年龄 Min,Max 37,69 42,67
;
run;
ods escapechar="^";
title;
footnote;
options nodate nonumber orientation=portrait missing=" ";
ods rtf file="D:\sas\example12.rtf" style=journalTest; /*journalTest是SAS本身自带的格式输出*/
proc report data=test headline headskip nowdstyle(report)=[pretext=%str("各类表格输出2")just=center font_size=10pt font_face="Roman" font_weight=bold];column class1 class2 ("^S={textdecoration=underline}分组" group1 group2);define class1/order order=data noprint;define class2/"分类" style(header)=[just=l indent=0 in]style(column)=[just=l cellwidth=2.8 in indent=.25 in];define group1/"实验组|           (N=15)";define group2/"对照组|           (N=13)";compute before class1;line " ";line @1 class1 $16.;endcomp;
run;
run;
ods rtf close;

十一、图表一

ods escapechar="^";
title;
footnote;
options nodate nonumber orientation=portrait missing=" ";
ods rtf file="D:\sas\example13.rtf";
proc sgplot data=sashelp.cars;hbox weight / category=origin;
run;
ods rtf close;

十二、图表二

ods escapechar="^";
ods graphics on;
ods output Survivalplot=SurvivalPlotData;
proc lifetest data=sashelp.BMT plots=survival(atrisk=0 to 2500 by 500);time T*Status(0);strata Group/test=logrank adjust=sidak;
run;
ods graphics off;
title;
footnote;
options nodate nonumber orientation=portrait missing=" ";
ods rtf file="D:\sas\example14.rtf";
proc sgplot data=SurvivalPlotData;step x=time y=survival / group=stratum lineattrs=(pattern=solid thickness=2)name='s' curvelable splitchar='-';scatter x=time y=censored / markerattrs=(symbol=circlefilled) name='c';scatter x=time y=censored / markerattrs=(symbol=circlefilled) GROUP=stratum;xaxistable atrisk / x=tatrisk location=outside class=stratum colorgroup=stratumvalueattrs=(size=8) labelattrs=(size=8);keylegend 'c' / location=inside position=topright;
run;
ods rtf close;

【直播笔记】在临床研究中,如何利用SAS做更好的统计报表输出相关推荐

  1. rr与hr_RR OR HR傻傻分不清楚——带你区分临床研究中的“3R”

    RR/OR/HR 傻傻分不清楚 -- 助你区分临床研究中的 " 3R " 在临床研究结果中,常常会看到 OR 值. RR 值. HR 值这 3 个统计学指标,它 们究竟代表什么意义 ...

  2. 临床研究中的基因组学、药物基因组学、蛋白质组学和转录组学 Omics in Clinical Practice: Genomics, Pharmacogenomics, Proteomics, and

    本书是对基因组学.蛋白质组学和转录组学的介绍,将这些领域与人类疾病和病症联系起来.各个章节考虑了翻译和个性化医疗的作用,以及与基因组学.蛋白质组学和转录组学有关的病原体检测.进化和感染.此外,还涉及到 ...

  3. 契约测试(中):利用PACT做契约测试

    软件质量保障 阿里巴巴资深测试开发工程师,工作重点为微服务测试.接口测试平台研发等. 主要分享软件测试以及测试开发博文,记录工作中的所思所获,介绍互联网大厂测试基建相关技术. 针对契约测试市面上提供了 ...

  4. 从制造中来到制造中去 华为要做更懂制造的“懂行人”

    通过自身技术实践与能力输出,华为正在帮助制造企业加速向智能制造转型. 出品 | 常言道 作者 | 丁常彦 俗话说,无农不稳,无工不富,无商不活.但在这三个产业中,工业是真正具有强大造血功能的产业,对经 ...

  5. Java从电脑一个txt文档中读入一篇英语文章,然后统计并输出文章中的单词和其对应的数目。

    简化版的:缺陷是没有消除大小写的区别,功能是实现了的. package ioTest; import java.awt.List; import java.io.BufferedReader; imp ...

  6. 临床研究和医疗保健行业实现数据湖架构的机会和挑战

    ERT首席数据官Prakriteswar Santikary博士上个月在2018年数据架构峰会上做了演讲,在演讲中他谈到了他的团队在其临床研究组织开发的数据湖架构.他讨论了部署在云中的数据平台,使用无 ...

  7. 多元有序logistic回归分析_一文详述:观察性研究中的logistic回归分析思路

    本文内容来自<中华流行病学杂志>2019年第40卷第8期,作者为冯国双教授,原题目为<观察性研究中的logistic回归分析思路>.将这篇文章分享给医咖会的伙伴们,希望大家能从 ...

  8. 用R来做一个临床研究亚组分析的森林图

    在编程语言里R语言最强大的功能是做图功能,我们知道在做Meta分析的时候会需要做森林图,实际上我们在很多临床研究中也经常看到森林图,主要是亚组分析的森林图,比如下面这篇文章里的一个森林图: 今天就教教 ...

  9. 样本量计算PASS软件提高临床研究可靠性的利器

    临床研究样本量的计算是医学研究中非常重要的一步,正确的样本量计算可以提高研究的可靠性和准确性.PASS是一款广泛应用的临床研究样本量计算软件,该软件以其简单易用.功能齐全和准确性高等特点而受到广泛的欢 ...

  10. 脑科学研究中常用的神经电信号记录电极介绍

    <本文同步发布于"脑之说"微信公众号,欢迎搜索关注~~> 在脑科学和神经科学的研究中,神经电生理信号(如脑电EEG.局部场电位LFP.动作电位Spike等)是领域内研究 ...

最新文章

  1. Relay外部库使用
  2. 使用mii-tool设置网卡速率
  3. 查看电脑python虚拟环境-手把手教你在Linux系统下使用Python虚拟环境
  4. 设计模式-Builder模式
  5. 【剑指offer】最长不含重复字符的子字符串
  6. Weka学习一(分类器算法)
  7. T-SQL笔记6:GO
  8. [dhtmlx]group task 失效问题解决
  9. String通过“+”号拼接字符串的底层实现
  10. C语言-用指针实现内存动态分配
  11. 如何实现一个HTML5 RPG游戏引擎——第二章,实现烟雨和雪飞效果
  12. 推荐系统实践---第一章:好的推荐系统
  13. 题目96:把一张一元的钞票换成一分、两分、和五分的硬币,每种硬币至少一枚。问有哪几种换法?
  14. excel软件做折线图
  15. 单总体分布卡方拟合优度检验
  16. vue pc端调用摄像头进行拍照并实现裁剪上传
  17. 以神奇“三”为本的逻辑与指号学----皮尔斯逻辑之三
  18. RK3399 focaltech敦泰触摸屏移植调试
  19. ubuntu18.04 台式机无线网卡TPLink WDN5200H2.0驱动安装
  20. 数组数据结构的使用与代码编写(一)

热门文章

  1. pip安装使用镜像工具pqi
  2. php 自适应 博客,三种方法让网站背景自动适应各浏览器大小
  3. 华硕 梅林系统 wan FTP 端口转发
  4. gromacs 中关于二级结构分析
  5. 安全L2-1.4-安全术语介绍
  6. 免费在线绘制CircRNA吸附miRNA圈图
  7. L1-1 寻找250(10 分)
  8. C语言自然数各自出现的次数,2010年计算机等考二级C语言上机考试练习(1)
  9. 佛祖保佑,永无bug,代码注释大全
  10. JAVA餐厅线上点菜系统计算机毕业设计Mybatis+系统+数据库+调试部署