# CELLSTYLE AS Statement

Sets the style element of the cells in the column according to the values of the variables. Use this statement to set the presentation characteristics (such as foreground color, font face, and flyover) of individual cells in all destinations except the LISTING destinations.
 Restriction: The CELLSTYLE AS statement can be used only with the DEFINE CELLVALUE statement. See: Creating a Customized Crosstabulation Table Template with No Legend

## Syntax

CELLSTYLE expression-1 AS
;

### Required Argument

expression
is an expression that is evaluated for each cell. If expression resolves to TRUE (a nonzero value), the style element that is specified is used for the current cell. If expression is FALSE (zero), the next expression in the statement is evaluated. Thus, you can string multiple expressions together to format cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n>
expression
is an arithmetic or logical expression that consists of a sequence of operators and operands. An operator is a symbol that requests a comparison, logical operation, or arithmetic calculation. An operand is one of the following:
1
is a fixed value that you can use to set a constant style element.
Example:These statements set the cellvalue Frequency background to gray:
```define cellvalue Frequency;
other–statements ...;
cellstyle 1 as {backgroundcolor=gray};
end;```
_VAL_
is the value of the current cell.
Example:The following statements change the foreground color of the cellvalue Percent depending on its magnitude:
```define cellvalue Percent;
other–statements ...;
cellstyle _val_ > 75.00 as {color=red},
_val_ > 50.00 as {color=orange}, _val_ > 25.00 as {color=green};
end;```
comparison-operator
compares a variable with a value or with another variable.
Comparison Operators
Symbol
Mnemonic Equivalent
Definition
=
EQ
Equal to
^= or ~= or ¬= or <>
NE
Not equal to
>
GT
Greater than
<
LT
Less than
>=
GE
Greater than or equal to
<=
LE
Less than or equal to
IN
Equal to one from a list of values
Tip:Using an expression of 1 as the last expression in the CELLSTYLE AS statement sets the style element for any cells that did not meet an earlier condition.

### Optional Arguments

style-attribute-specification
describes a style attribute to set. Each style-attribute-specification has this general form:
style-attribute-name=style-attribute-value
For information about the style attributes that you can set in a column template, see Detailed Information for All Style Attributes.
Default:If you do not specify any style attributes to modify, ODS uses the unmodified style-element-name.
Note:Neither style-attribute-specification nor style-element-name is required. However, you must use at least one of them.
style-element-name
is the name of the style element that displays the data in the column. The style element must be part of a style that is registered with the Output Delivery System. SAS provides some styles. You can create customized styles by using PROC TEMPLATE (see By default, ODS displays different parts of ODS output with different style elements. For example, by default, the data in a column is displayed with the style element Data. The style elements that you would probably use with the CELLSTYLE AS statement in a column template are the following:
• Data
• DataFixed
• DataEmpty
• DataEmphasis
• DataEmphasisFixed
• DataStrong
• DataStrongFixed
The style element provides the basis for displaying the column. Additional style attributes that you provide can modify the display.
Default:Data
Note:Neither style-attribute-specification nor style-element-name is required. However, you must use at least one of them.