SAS Proc 报表样式

SAS Proc report style

我正在编写一个代码来显示以下记录和过程报告。我想用红色突出显示每一行的最大数量。我已经尝试过代码,但它突出显示了不同的值。请在以下代码中提供更正以正确显示突出显示的值。

    data records;
    input a1 a2 a3 a4 a5;
    cards;
    37 95 80 52 85 
    94 .  7  10 14 
    64 5  71 14 92 
    .  55 38 .  46 
    ;
    run;

    proc report data=records nowd;
    column a1 a2 a3 a4 a5;
    define a1/display;
    define a2/display;
    define a3/display;
    define a4/display;
    define a5/display;

    compute a1;
    if a1=Max(a1,a2,a3,a4,a5) then call define('a1','style','style={foreground=white background=red}');
    endcomp;
    compute a2;
    if a2=Max(a1,a2,a3,a4,a5) then call define('a2','style','style={foreground=white background=red}');
    endcomp;
    compute a3;
    if a3=max(a1,a2,a3,a4,a5) then call define('a3','style','style={foreground=white background=red}');
    endcomp;
    compute a4;
    if a4=max(a1,a2,a3,a4,a5) then call define('a4','style','style={foreground=white background=red}');
    endcomp; 
    compute a5;
    if a5=max(a1,a2,a3,a4,a5) then call define('a5','style','style={foreground=white background=red}');
    endcomp; 
    run;

据我所知,如果您使用计算语句,顺序很重要。所以如果你用compute a1,那时候只有a1有值,compute a2就是只有a1和a2有值,以此类推...

因此您必须将最后一列用于计算语句,然后所有列都有值并且结果应该没问题。

Sas page 上找到这个:

Note: The position of a computed variable is important. PROC REPORT assigns values to the columns in a row of a report from left to right. Consequently, you cannot base the calculation of a computed variable on any variable that appears to its right in the report

所以试试这个方法,它对我有用:

proc report data=records nowd;
column a1 a2 a3 a4 a5;
define a1/display;
define a2/display;
define a3/display;
define a4/display;
define a5/display; 

compute a5;
if a1=Max(a1,a2,a3,a4,a5) then call define('a1','style','style={foreground=white background=red}');
if a2=Max(a1,a2,a3,a4,a5) then call define('a2','style','style={foreground=white background=red}');
if a3=max(a1,a2,a3,a4,a5) then call define('a3','style','style={foreground=white background=red}');
if a4=max(a1,a2,a3,a4,a5) then call define('a4','style','style={foreground=white background=red}');
if a5=max(a1,a2,a3,a4,a5) then call define('a5','style','style={foreground=white background=red}');
endcomp; 
run;