
5.10 使用style=option定制proc tabulate输出
下面显示了proc tabulate语句中可以应用style的地方,并且影响的表区域:

Proc tabulate语句 如果想要来自数据集MYSALES的表的所有数据单元都变成黄色背景:
PROC TABULATE DATA=mysales STYLE={BACKGROUND=yellow};
Table语句 下面的代码使得all列都有红色背景:
TABLE City,Month ALL*{STYLE={BACKGROUND=red}};
CLASSLEV,VAR,和CLASS statements CLASSLEV,VAR,和CLASS语句都是在斜杠/后面应用style语句。注意的是,classlev语句中的变量必须出现在class语句中,下面的代码是将月份month变量的每个值(Jan,Feb,Mar…)的前背景应用为绿色,使用classlev语句如下:
CLASSLEV Month/STYLE={FOREGROUND=green};
例子 下面是一份关于奥运会男子滑冰的数据,OR是奥运会纪录,WR是世界记录,NONE既不是奥运会记录,也不是世界记录。注意一行有四个观测值:

Tabulate过程建立了一个表,以年份作为行,记录作为列。年份和N的顶部都通过设置为null将其消除。ODS语句创建了HTML文件,使用默认模板:

结果如下:

现在将数据单元的数据居中,并将背景设置为白色:

显示结果为:

5.11 为你的输出增加交通信号灯
交通信号灯是基于单元格的值,来控制格的风格。它可以使得重要值变得醒目,它可以在print、report、tabulate中被使用。
使用之前需要做两件事:首先创建用户定义的格式。其次,在style=中将风格属性等于你定义的格式,比如,你创建了一个格式:

在print的VAR语句中,将属性值等于这个格式:
VAR Balance/STYLE={FOREGROUND=posneg.};
现在所有balance变量风格都发生变化。
例子 下面的数据是2002年冬奥会中,男子5000米滑冰前五名的数据,包括姓名、国家、成绩(用时)

下面代码读取打印数据,生成HTML文件,使用default模板:

结果为:

想要用信号灯显示每个成绩与世界记录的378.72、奥运记录382.20比较的结果,先创建用户自定义的格式REC,快于世界记录的用红色显示,橙色显示快于奥运记录的,其他颜色设置白色。接着在print语句中增加var语句,使用style=option为时间变量分配风格。最后,将定义的格式REC赋给background。

结果如下:

5.12 选择风格属性




网友评论