全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
20537 13
2013-01-15
悬赏 50 个论坛币 已解决

在不改变原数据集的情况下,直接使用proc report产生报告,要求:字符过长换行的时候自动在前面产生两个或三个空格,与本身对齐。(如果解释起来比较麻烦,想能推荐资料,是否有这样的功能)

原数据集:(1.2.3.前面有两个空格,表示子项)

病理诊断                                                                                                        日期

  1.某某某 某某某 某某某某某某某 某某某某某某某。             2012/01/25

  2. 某某某某某某  某某。                                                                    2012/01/25

  3. 某某某某某某  某某某某某某某某。                                          2012/01/25

得到结果:

病理诊断                                                             日期

    1.某某某 某某某 某某某某                   2012/01/25

某某某 某某某某某某某。                  

    2. 某某某某某某  某某。                        2012/01/25

    3. 某某某某某某  某某某                        2012/01/25

某某某某某。   

   

需要report出来的样子:

病理诊断                                                             日期

    1.某某某 某某某 某某某某                   2012/01/25

    某某某 某某某某某某某。                  

    2. 某某某某某某  某某。                        2012/01/25

    3. 某某某某某某  某某某                        2012/01/25

    某某某某某。                          

下面是我的report,但是做不出那样的对齐功能:查了一些proc compute资料,要么是在数据before,要么是after,都无法实现(只是个例子,并不与上面数据所对应)。

*** Output file as rtf file using PROC REPORT;

ods listing close;

ods rtf file="&_table.t&PgmNm..rtf" style=global.rtf;

title2 "Table &TFLNo. (&_page.)";

footnote3 j=l "n = number of patients experiencing event    c = number of events";

proc report data=qc_tab.t_&PgmNm headskip spacing=1 split='|' missing nowd

  style(header)=[just=center protectspecialchars=off]

      style(column)=[just=center asis=on];

  column  _var_ date;

  define _var_     / display "System Organ Class|Preferred Term" flow style(column)=[cellwidth=35% just=left] style(header)=[just=left];

  define date      / display "Nilotinib|N=&n1 |n(%)/c" flow

style(column)=[cellwidth=15%] style(header)=[just=center];

/*  break after _group / skip;*/

run;

ods rtf close;

ods listing;   

最佳答案

pobel 查看完整内容

这个应该需要用到RTF code来控制。 1. 首先要加上ODS的escapechar=选项。 如 ods excapechar="^"; 2. 楼主需要的效果应该属于缩进,相对应的RTF code是: ^R'\li400 ' 400 可以换成其他的数,数的大小表示缩进的多少。 楼主需要在数据集中将_var_变量需要缩进的值前面加上这个RTF code。 (不同版本的office,RTF code可能会不同) 楼主可以试一下下面的代码: %let indent=^R'\li400 '; data * ...
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-1-15 11:29:10
a6566792 发表于 2013-1-15 15:17
额,大家都不知道吗?
  希望Imasasor、davil2000 、大数据之魂、playmore、peble 等其他几位高人能给点提 ...
这个应该需要用到RTF code来控制。

1. 首先要加上ODS的escapechar=选项。
   如 ods excapechar="^";

2. 楼主需要的效果应该属于缩进,相对应的RTF code是: ^R'\li400 '
    400 可以换成其他的数,数的大小表示缩进的多少。
   楼主需要在数据集中将_var_变量需要缩进的值前面加上这个RTF code。
   (不同版本的office,RTF code可能会不同)

楼主可以试一下下面的代码:

%let indent=^R'\li400 ';

data ***;
   set ***;
   _all_="&indent."||_var_;
run;


*** Output file as rtf file using PROC REPORT;
ods listing close;
ods rtf file="&_table.t&PgmNm..rtf" style=global.rtf;
ods escapechar='^';

title2 "Table &TFLNo. (&_page.)";
footnote3 j=l "n = number of patients experiencing event    c = number of events";


proc report data=qc_tab.t_&PgmNm headskip spacing=1 split='|' missing nowd
  style(header)=[just=center protectspecialchars=off]
      style(column)=[just=center asis=on  protectspecialchars=off];
  column  _var_ date;
  define _var_     / display "System Organ Class|Preferred Term" flow style(column)=[cellwidth=35% just=left] style(header)=[just=left];
  define date      / display "Nilotinib|N=&n1 |n(%)/c" flow
style(column)=[cellwidth=15%] style(header)=[just=center];
/*  break after _group / skip;*/
run;

ods rtf close;

ods listing;   
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-1-15 15:17:32
额,大家都不知道吗?
  希望Imasasor、davil2000 、大数据之魂、playmore、peble 等其他几位高人能给点提示。。。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-1-15 18:12:01
a6566792 发表于 2013-1-15 15:17
额,大家都不知道吗?
  希望Imasasor、davil2000 、大数据之魂、playmore、peble 等其他几位高人能给点提 ...
不要把我跟他们相提并论,不要以为是版主就有多牛,我跟他们根本不是一个级别的
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-1-16 09:35:25
pobel 发表于 2013-1-15 17:30
这个应该需要用到RTF code来控制。

1. 首先要加上ODS的escapechar=选项。
我需要的不仅仅是变量的缩进,上面‘病理诊断’也是数据中的,相当于目录的样子,它不需要缩进,仅仅是下面的子项缩进,您的建议相当好,我马上去试试,也可能需要再结合一下compute <column> if then 功能
[em17][em17]
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-1-16 09:37:47
Imasasor 发表于 2013-1-15 18:12
不要把我跟他们相提并论,不要以为是版主就有多牛,我跟他们根本不是一个级别的
额,都是前辈,或者前前辈……
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群