楼主: wayne0524
2395 10

高手进! column 制表问题~ [推广有奖]

  • 25关注
  • 6粉丝

讲师

40%

还不是VIP/贵宾

-

威望
0
论坛币
4529 个
通用积分
8.3706
学术水平
30 点
热心指数
44 点
信用等级
30 点
经验
8310 点
帖子
367
精华
0
在线时间
488 小时
注册时间
2007-2-3
最后登录
2022-11-2

20论坛币
proc report data= mo.Os_baoan  out = aa;                                                           
column FLAG   baoan_dis  N ;                                                                                                            
define FLAG/group ;                                                                                                                     
define sumclaim /analysis sum;                                                                                                         
define baoan_dis/across ;                                                                                                               
run;            

程序如上,结果如下图

FLAG

本季

本年非本季

其他年份

上年

N

报案注销

9

9

10

71

99

拒赔

 

 

 

1

1

立案注销

1

 

 

14

15

正常

300

209

101

845

1455

重开

3

 

12

14

29




问题一:如何使 proc report 的column 制表结果输出成 html 的网页版格式,
问题二,baoan_dis 维度被展开了一共有四个维度,我想新生成一列字段对 baoan_dis 字段维度下的 本年非本季 和其他年份 的两个维度加总
求高手帮修改以上程序 或者 举例子其他类似程序 实现 我想要的上面的操作。
谢谢!
补充问题三:横向维度整体求和有 N 统计量解决,如何修改代码使得实现对纵向统计量的求和 ,即如何让展示表格产生新一行 统计 报案注销,拒赔,立案注销,正常,重开的 汇总??
求解

补充问题四:baoan_dis 维度被展开了一共有四个维度,如何使得其中“本季的”维度 那一列的表格背景颜色变黄?

最佳答案

yongyitian 查看完整内容

Hi Wayne, I really don’t know how to hide a level of an across variable. But the whole a group or an across variable can be hidden using noprint option, such as Define flag / group noprint; Define baoan / across noprint; I modified the code by using COMPUTE block to calculate the sum of B1 and B4, instead of calculating it in a data step. proc report data=test nowd; column flag b ...
关键词:column colum proc report Analysis Analysi across report 程序
沙发
yongyitian 发表于 2013-2-18 18:38:57 |只看作者 |坛友微信交流群
Hi Wayne,
I really don’t know how to hide a level of an across variable. But the whole a group or an across variable can be hidden using noprint option, such as
Define flag / group noprint;
Define baoan / across noprint;


I modified the code by using COMPUTE block to calculate the sum of B1 and B4, instead of calculating it in a data step.  

proc report data=test nowd;
   column flag baoan N B1B4;
   define flag /group;
   define baoan / across;
   define KK / analysis;
   rbreak after / summarize;          /* add a summary at the bottom */
   compute B1B4;
         B1B4 = sum(_C2_, _C4_); /* _C2_ and _C4_ are the second and the 4th colomn in the output table */
   endcomp;
   where Baoan in ('B1' 'B2' 'B4');
run;

In addition,  using data step you can get more you want.
data test_1;
     set test;
         if first.flag then do;
             B1=0; B2=0; B3=0; B4=0;
                     if baoan = 'B1' then B1 = 1;
                 if baoan = 'B2' then B2 = 1;
               if baoan = 'B3' then B3 = 1;
               if baoan = 'B4' then B4 = 1;
                  end;
      else do;
             if baoan = 'B1' then B1+1;
                 if baoan = 'B2' then B2+1;
                         if baoan = 'B3' then B3+1;
                         if baoan = 'B4' then B4+1;
                end;
                B14 = B1 + B4;
        if last.flag then output;
        by flag;
        drop baoan;
  run;     

使用道具

藤椅
咕舟蓑笠 发表于 2013-2-19 02:42:05 |只看作者 |坛友微信交流群
问题一:
ODS HTML File = 'filename';
PROC REPOER DATA=mo.Os_baoan nowindows;  /*nowindows是关键*/
your other statements;
ODS HTML CLOSE;

问题二:
我也不知道,等待高手回答。
已有 1 人评分热心指数 收起 理由
wayne0524 + 1 谢谢!

总评分: 热心指数 + 1   查看全部评分

使用道具

板凳
wayne0524 发表于 2013-2-19 10:06:44 |只看作者 |坛友微信交流群
咕舟蓑笠 发表于 2013-2-19 02:42
问题一:
ODS HTML File = 'filename';
PROC REPOER DATA=mo.Os_baoan nowindows;  /*nowindows是关键*/  ...
第一个问题解决  谢谢~!
求高手解后两个~

使用道具

报纸
yongyitian 发表于 2013-2-19 12:18:57 |只看作者 |坛友微信交流群
问题二, 三
sumclaim 是不是应该出现在 column 语句中

Try to add following  before  run;

rbreak after / summarize;

使用道具

地板
wayne0524 发表于 2013-2-19 15:29:12 |只看作者 |坛友微信交流群
yongyitian 发表于 2013-2-19 12:18
问题二, 三
sumclaim 是不是应该出现在 column 语句中
您好,我看不太明白你的意思 ,能给我解释清楚些么,比如 我想让以上的表格结果多一列,就叫KK吧,内容就是本季和上年的加总(注意本季和上年在原始清单中不是独立的字段,在原始清单中是隶属于baoan_dis字段维度下),请问如何修改程序实现呢?
求解

使用道具

7
yongyitian 发表于 2013-2-19 23:46:39 |只看作者 |坛友微信交流群

Data test;    /* this is simulated dataset */

input flag  $ baoan $;

datalines;

F1    B1

F1    B1

F1    B2

F1    B3

F1    B3

F1    B3

F1    B4

F1    B4

F1    B4

F1    B4

F2    B4

F3    B1

F3    B4

F3    B4

F3    B4

F3    B4

F4    B1

F4    B2

F4    B3

F4    B3

F4    B3

F4    B4

F5    B1

F5    B1

F5    B1

F5    B3

F5    B4

F5    B4

; run;

data test_kk;  /* add new column KK */

   set test;

   if baoan='B1' or baoan='B4' then KK =1;  

run;

proc report data=test_kk nowd;

   column flag baoan N KK;

   define flag /group;

   define baoan / across;

   define KK / analysis;

   rbreak after / summarize;  /* add a summary at the bottom */

run;     

已有 1 人评分学术水平 热心指数 收起 理由
wayne0524 + 1 + 1 谢谢!

总评分: 学术水平 + 1  热心指数 + 1   查看全部评分

使用道具

8
wayne0524 发表于 2013-2-20 09:15:18 |只看作者 |坛友微信交流群
yongyitian 发表于 2013-2-19 23:46
Data test;    /* this is simulated dataset */input flag  $ baoan $;datalines;F1    B1F1    B1F1    B ...
太感谢了!只需要补充一个标记维度让两者相加,我太笨了,呵呵。。。基本问题都解决了!过会还没人答题了 我就把分数给你!
谢谢。

另外 ,我刚才突然有想到出来一个问题,还是上面的例子,baoan 下的维度一共四个,经过define baoan/across 后四个维度全部就展开了,而KK 是B1 和B4  的加总  ,假设 KK 剩余的空白的维度 我们编号为2 ,难么KK字段下就有两个维度。问题来了,如果我其实只想使用baoan 字段下的的B1  维度,和KK字段下的编号为1的B1+B4结果的 维度,剩下的都不要,这时候 ,加where baoan ="B1"语句后,KK字段的展示结果也变成了只有B1,而没有了我需要相加的B4的结果.

请问如何解决以上问题??

如果有空,还劳烦大侠再赐教!

使用道具

9
yongyitian 发表于 2013-2-20 09:31:39 |只看作者 |坛友微信交流群
wayne0524 发表于 2013-2-20 09:15
太感谢了!只需要补充一个标记维度让两者相加,我太笨了,呵呵。。。基本问题都解决了!过会还没人答题了 ...
add a where condition as follows

proc report data=test_kk nowd;
   column flag baoan N KK;
   define flag /group;
   define baoan / across;
   define KK / analysis;
   rbreak after / summarize;  /* add a summary at the bottom */
   where baoan in ('B1' 'B2' 'B4');    /* add here */
run;

使用道具

10
wayne0524 发表于 2013-2-20 09:40:04 |只看作者 |坛友微信交流群
yongyitian 发表于 2013-2-20 09:31
add a where condition as follows

proc report data=test_kk nowd;
where  我刚才想到了,我修改了一下上上楼的 补充的问题 您有空再帮看看 谢谢

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-27 14:52