SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 2784|回复: 12
打印 上一主题 下一主题

SAS如何输出如下的表格?

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2004-5-29 16:13:43 | 只看该作者

SAS如何输出如下的表格?

不知这种表格如何用SAS实现?
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2004-5-30 11:51:40 | 只看该作者
我觉得恐怕有些难度,表现在如下:
1.有两个统计量放在一个格子中
2.class变量(性别)和var 变量(年龄)同时放在一张表的横行中。

我只能通过proc tabulate 得到两张表,而且每一个统计量(频数、百分比)只能放在独立一个横行中。
代码:
proc tabulate data=tem;
class 性别 药物1 药物2;
table
(性别 all)*(n colpctn),(药物1 药物2);
run;

proc tabulate data=tem;
class 药物1 药物2;
var 年龄
table
(年龄 all)*(n nmissing mean std median min max),(药物1 药物2);
run;

不知道哪位高手能把两张报表和起来。:)
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2004-5-31 10:03:40 | 只看该作者
就是这样的呀,不知report过程能否完成这样的任务?
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
地板
 楼主| 发表于 2004-6-2 14:58:05 | 只看该作者

可以试试采用sas宏程序

思路是:
1)将分析结果导入sas数据集;
2)将原来在LOG窗口显示的内容重定向到txt fille上;
3)利用类似“put #row@col &vari &fmt ”的命令绘制表格
4)启用宏

具体程序可检索“【论文题名】定性指标的SAS统计分析报表--SAS软件在新药临床试验统计分析中的应用(一)  【作  者】童新元 张高魁 姚晨 ”的论文
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
5#
 楼主| 发表于 2004-6-2 22:20:46 | 只看该作者

another solution

其实tomtalk基本都解决了,就差一点点。比如:
[code:11798]
data class;
set sashelp.class;
if ranuni(111)>.5 then do;
   type='药物一';
   if ranuni(123)>.5 then id='A';
   else id='B';
end;
else do;
   type='药物二';
   if ranuni(234)>.5 then id='A';
   else id='B';
end;
run;

proc print;run;

ods html file="c:\123.htm" style=statdoc;

proc tabulate data=class;
class sex type id;
var age;
table sex age*(mean median max min),type*id;
run;quit;

ods html close;[/code:11798]
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
6#
 楼主| 发表于 2004-6-2 22:22:48 | 只看该作者

1111

其他的修饰,我也无心研究,自己看吧
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
7#
 楼主| 发表于 2004-6-2 23:56:49 | 只看该作者

感谢

非常感谢[color=blue:00957]tomwalk evening123 willon[/color:00957]的指点,根据你们的思路我再去研究研究!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
8#
 楼主| 发表于 2004-6-3 11:17:49 | 只看该作者

想知道这段程序出错的原因是什么

sas code:

ods html path='c:\'(url=none) body='1.htm' ;
proc tabulate data=class;
class sex type id;
var age;
table sex age*(mean median max min),type*id;
run;quit;
ods html close;


LOG:

ERROR:  Read Access Violation In Task ( Submit ]
Exception occurred at (63CC5C0D)
Task Traceback

ods html path='c:\'(url=none) body='1.htm' ;
NOTE: Writing HTML Body file: 1.htm
ERROR: Generic critical error.

editor的状态也不正常,始终显示“正在处理提交的任务中”
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
9#
 楼主| 发表于 2004-6-3 11:37:29 | 只看该作者

假如还要求在求得mean的基础上,出95%置信区间的结果呢?

用哪个过程可以出n nmiss mean std median qrange 同时还要95%CI.

hehe,搞定了。应该是proc means里面的lclm和uclm选项。
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
10#
 楼主| 发表于 2004-6-3 13:40:49 | 只看该作者

A conventional way to do this table

It is a typical demographic table in clinical trial analysis.  Although it might be created by PROC TABULATE, I still suggest all of you trying to write a SAS program in a more complicated way as follows (at least as a home work assignment).

1. Use Proc Freq to calculate the frequencies and percentage, save the result into a SAS data set.
2. Use Proc Means to calculate means and stds and save the result into a SAS data set.
3. reformulate each columns and append the two result data sets.
4. create table by Proc Report.

The way to do this is generally referred as customized reporting, which means to create a report based on given template.  

In the previous example, if I make just small changes to that table structure, Proc Tabulate will never do it.  

Using the default output of a PROC, the flexibility of the output format is very limited.  A good SAS programmer should be able to follow the requirements exactly, in case the requiremements are reasonable.  It is a key difference between the people working in industry and academic fields.  

It is for sure that any kind of report can be created by using PUT statement, but that kind of skill is rarely used with the standardization of clinical trial reporting.

Just my 2 cents.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-6-8 21:47 , Processed in 0.073913 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表