2016-02-05 85 views
0

数据集in包含4栏col1-col4。我试图创建一个将4列分成两部分的输出。proc报告跨页眉颜色

在下面的代码,通过将假可变blank,我可以部分A和B部分之间添加一个空栏。

options missing=''; 
proc report data=in missing 
style(header)=[background=steelblue]; 
column ('Part A' col1 col2) blank ('Part B' col3 col4); 
define blank/computed ' ' style=[background=white]; 
define col1/display style[background=tan]; 
... 
compute blank; 
blank = .; 
call define(_col_,'style','style={background=white borderbottomcolor=white}'); 
endcomp; 
run; 

的问题是我需要

  1. 两种不同的颜色跨越头和“原始”的标题。

  2. 两个跨页眉之间的列应全部为白色。

但是代码不能达到第二个目的。

电流输出看起来像

1st row ------  Part A  Part B (steelblue for entire row) 

2nd row ------ col1 col2  col3 col4 (col1-col4 are tan, the column between col2 and col3 and white) 

但所需的输出是

1st row ------  Part A  Part B (steelblue for Part A & B, but the column between them should be white) 

2nd row ------ col1 col2  col3 col4 (col1-col4 are tan, the column between col2 and col3 and white) 

我发现这个职位,但我甚至无法复制辛西娅”输出。 proc格式似乎不起作用。

Proc Report - Coloring for Spanning Headers

这是Excel相当容易 - 只需插入一个新的空栏,没有填充该列。我如何在SAS中做到这一点?

回答

1

你没有提到ODS目的地。这适用于HTML和PDF(有点)。 我认为关键假设它实际上做你想要的是使用'a0'x ascii non-breaking space。但是这并没有完全测试。

title; 
options missing=''; 
proc format; 
    value $color 
     'a0'x = 'white' 
     other='steelblue' 
     ; 
proc report data=sashelp.class missing 
    style(header)=[background=$color. borderbottomcolor=$color.]; 
    column ('Part A' name sex) ('a0'x blank) ('Part B' age weight height); 
    define _all_/display style=[background=tan]; 

    define blank/computed 'a0'x 
     style=[background=white borderbottomcolor=white] 
     style(header)=[background=white borderbottomcolor=white]; 

    compute blank/char length=1; 
     blank = ' '; 
     call define(_col_,'style','style={background=white borderbottomcolor=white}'); 
     endcomp; 
    run; 

enter image description here

+0

它不会对EG 6.1 .. – Lovnlust

+0

工作,如果我取代'$ color.'一些预定义的颜色,它的工作原理。因此,proc格式部分似乎不适用于输出。 – Lovnlust

+0

它不适用于ODS tagsets.sasreport13(ID = EGSR)SAS EG报告目标,我在我的答案中暗示“这适用于HTML” –

0

Cynthia发布的代码包含语法错误(proc报告中的标题+ style(header)行缺少;)。

有了修正,这对我的作品(SAS 9.3 AIX):

 
proc format; 
    value $color 
      'REPORT' = '#9999FF' 
      'Australia' = '#FF6600' 
      'States' = 'pink' 
      'Wombat' = 'lightgreen' 
      other = 'lightblue'; 

    value $altclr 
      'REPORT' = '#9999FF' 
      'Australia' = '#FF6600' 
      'States', 'Height', 'Weight' = 'pink' 
      'Wombat', 'Name', 'Age', 'Sex' = 'lightgreen' 
      other = 'lightblue'; 
run; 

ods listing close; 
ods tagsets.excelxp file = "%SYSFUNC(pathname(work))./Test.xml" 
    options (embedded_titles='yes') style = sansprinter; 

title 'All Headers Different Colors Based on Formats'; 
proc report data = sashelp.class(obs=3) nowd 
    style(header) = { background = $color. font_size= 10pt }; 
    column ('REPORT'('Australia' ('Wombat' name age sex)('States' height weight))); 
run; 

title 'Some Headers Same Colors Based on Formats (one header diff)'; 
proc report data = sashelp.class(obs=3) nowd 
    style(header) = { background = $altclr. font_size= 10pt }; 
    column ('REPORT'('Australia' ('Wombat' name age sex)('States' height weight))); 
    define name/'Name'; 
    define age/'Age'; 
    define sex/'Sex'; 
    define height/'Height'; 
    define weight/'Weight' style(header)={background=lightyellow}; 
run; 

ods _all_ close;