我在 SAS 中输出了两个交叉表:一个用于 Time0,一个用于 Time1。我很感兴趣将第一个交叉表中每个单元格的值变化与第二个交叉表中的值变化进行比较。
是否有一种聪明的方法可以根据与另一个交叉表中的等效单元格的比较来更改单元格的背景颜色?如果不是,并且我使用 Time0 和 Time1 之间的变量变化创建了一个变量,如何根据值是正数还是负数来更改交叉表的单元格颜色?如果单元格包含百分比变化,是否可以以 5% 的增量放置颜色渐变?
我有一些示例数据如下:
data have;
input username $ betdate : datetime. stake;
dateOnly = datepart(betdate) ;
format betdate DATETIME.;
format dateOnly ddmmyy8.;
datalines;
player1 12NOV2008:12:04:01 90
player1 04NOV2008:09:03:44 30
player2 07NOV2008:14:03:33 120
player1 05NOV2008:09:00:00 50
player1 05NOV2008:09:05:00 30
player1 05NOV2008:09:00:05 20
player2 09NOV2008:10:05:10 10
player2 15NOV2008:15:05:33 35
player1 15NOV2008:15:05:33 35
player1 15NOV2008:15:05:33 35
run;
proc sort data=have; by username betdate; run;
data have;
set have;
by username dateOnly betdate;
retain eventTime;
if first.username then eventTime = 0;
if first.betdate then eventTime + 1;
run;
proc sql;
create table playerStats as
select
distinct username,
(select distinct avg(stake) from have where username = main.username and eventTime <= 1) format comma10.2 as bet1AvgStake,
(select distinct avg(stake) from have where username = main.username and eventTime <= 2) format comma10.2 as bet2AvgStake,
(select distinct avg(stake) from have where username = main.username and eventTime <= 3) format comma10.2 as bet3AvgStake
from have main;
quit;
Proc rank data=playerStats ties=mean out=customerStats groups=2;
var bet1AvgStake bet2AvgStake;
ranks bet1AvgStakeRank bet2AvgStakeRank;
run;
PROC TABULATE DATA=customerStats NOSEPS;
VAR bet1AvgStake bet2AvgStake;
class bet1AvgStakeRank;
TABLE bet1AvgStakeRank, bet1AvgStake*(N Mean);
TABLE bet1AvgStakeRank, bet2AvgStake*(N Mean);
RUN;
当第二个交叉表中每个单元格的值低于第一个交叉表中的等效单元格时,我希望看到一个红色单元格,当值较高时,我希望看到一个绿色单元格。
感谢您对此的任何帮助。