SAS中文论坛

标题: SAS如何输出如下的表格? [打印本页]

作者: shiyiming    时间: 2004-5-29 16:13
标题: SAS如何输出如下的表格?
不知这种表格如何用SAS实现?
作者: shiyiming    时间: 2004-5-30 11:51
我觉得恐怕有些难度,表现在如下:
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;

不知道哪位高手能把两张报表和起来。:)
作者: shiyiming    时间: 2004-5-31 10:03
就是这样的呀,不知report过程能否完成这样的任务?
作者: shiyiming    时间: 2004-6-2 14:58
标题: 可以试试采用sas宏程序
思路是:
1)将分析结果导入sas数据集;
2)将原来在LOG窗口显示的内容重定向到txt fille上;
3)利用类似“put #row@col &vari &fmt ”的命令绘制表格
4)启用宏

具体程序可检索“【论文题名】定性指标的SAS统计分析报表--SAS软件在新药临床试验统计分析中的应用(一)  【作  者】童新元 张高魁 姚晨 ”的论文
作者: shiyiming    时间: 2004-6-2 22:20
标题: 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]
作者: shiyiming    时间: 2004-6-2 22:22
标题: 1111
其他的修饰,我也无心研究,自己看吧
作者: shiyiming    时间: 2004-6-2 23:56
标题: 感谢
非常感谢[color=blue:00957]tomwalk evening123 willon[/color:00957]的指点,根据你们的思路我再去研究研究!
作者: shiyiming    时间: 2004-6-3 11:17
标题: 想知道这段程序出错的原因是什么
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的状态也不正常,始终显示“正在处理提交的任务中”
作者: shiyiming    时间: 2004-6-3 11:37
标题: 假如还要求在求得mean的基础上,出95%置信区间的结果呢?
用哪个过程可以出n nmiss mean std median qrange 同时还要95%CI.

hehe,搞定了。应该是proc means里面的lclm和uclm选项。
作者: shiyiming    时间: 2004-6-3 13:40
标题: 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.
作者: shiyiming    时间: 2004-6-4 10:18
标题: 想实现第三步,请给个简单例子
3. reformulate each columns and append the two result data sets.
作者: shiyiming    时间: 2004-6-5 18:33
标题: reformulate the columns
For example, you have two data sets, each has two columns and one record.

In data A, x=345, y=342;
In data B, x=4.56 (23%), y=2.34 (56%);

You want a talbe printed out as

EXP of A           345              342
EXP of B           4.56 (23%)   2.34 (56%)

Since x and y in B are defintely character variables, if x and y in A are numeric, you have to convert them into character variables before you append A and B together.  Besides, you have to add EXPlainations to each row.  I refer these operations as reformaulte columns.
作者: shiyiming    时间: 2004-11-29 20:15
标题: Re: SAS如何输出如下的表格?
请问一个我想了好久的问题 各位大淫帮忙
一个数据集在报表输出时要求部分在左边输出一部分在右边输出格式如下
data temp;
input year sort  sort1 var1;
cards;
nike  1bf  10
nike  2bf  20
nike  3bf  30
nike  4bf  40
adi   1bf  12
adi   2bf  13
adi  3bf  24
adi  4bf  30
ban 1bf  10
ban  2bf  12
ban  3bf  31
ban  4bf  34
kwi 1bf  10
kwi 2bf  12
kwi 3bf  31
kwi 4bf  34
;
run;

现在我想输出这样的报表 该怎么做;
以nike和adi为分类的在左边输出,而以ban和kwi为分类的变量在右边输出
我做过试验我将他们拆开再merge在一起用print输出,但是如果行分类变量
多了的话 就不好print了 ,请问我该怎么办,




欢迎光临 SAS中文论坛 (http://mysas.net/forum/) Powered by Discuz! X3.2