Shared Concepts

Effect Operators

Table 11 summarizes the operators that are available for selecting and constructing effects. These operators are discussed in the following sections.

Table 11: Available Effect Operators

Operator Example Description
Interaction A*B Crosses the levels of the effects
Nesting A(B) Nests A levels within B levels
Bar operator A | B | C Specifies all interactions
At sign operator A | B | C@2 Reduces interactions in bar effects
Dash operator A1-A10 Specifies sequentially numbered variables
Colon operator A: Specifies variables with common prefix
Double dash operator A- -C Specifies sequential variables in data set order


Bar and At Sign Operators

You can shorten the specification of a large factorial model by using the bar operator. For example, two ways of writing the model for a full three-way factorial model follow:

model Y = A B C   A*B A*C B*C   A*B*C;

model Y = A|B|C;

When the bar (|) is used, the right and left sides become effects, and the cross of them becomes an effect. Multiple bars are permitted. The expressions are expanded from left to right, using rules 2–4 in Searle (1971, p. 390).

  • Multiple bars are evaluated from left to right. For example, A | B | C is evaluated as follows:

    A | B | C right-arrow left-brace A | B right-brace | C
    right-arrow left-brace A  B  A*B right-brace | C
    right-arrow A  B  A*B  C  A*C  B*C  A*B*C

  • Crossed and nested groups of variables are combined. For example, A(B) | C(D) generates A*C(B D), among other terms.

  • Duplicate variables are removed. For example, A(C) | B(C) generates A*B(C C), among other terms, and the extra C is removed.

  • Effects are discarded if a variable occurs on both the crossed and nested parts of an effect. For example, A(B) | B(D E) generates A*B(B D E), but this effect is eliminated immediately.

You can also specify the maximum number of variables involved in any effect that results from bar evaluation by specifying that maximum number, preceded by an at sign (@), at the end of the bar effect. For example, the following specification selects only those effects that contain two or fewer variables:

model Y = A|B|C@2;

The preceding example is equivalent to specifying the following MODEL statement:

model Y = A B C   A*B A*C B*C;

More examples of using the bar and at operators follow:

A | C(B) is equivalent to A   C(B)   A*C(B)
A(B) | C(B) is equivalent to A(B)   C(B)   A*C(B)
A(B) | B(D E) is equivalent to A(B)   B(D E)
A | B(A) | C is equivalent to A   B(A)   C   A*C   B*C(A)
A | B(A) | C@2 is equivalent to A   B(A)   C   A*C
A | B | C | D@2 is equivalent to A  B  A*B  C  A*C  B*C  D  A*D  B*D  C*D
A*B(C*D) is equivalent to A*B(C D)

Colon, Dash, and Double Dash Operators

You can simplify the specification of a large model when some of your variables have a common prefix by using the colon (:) operator and the dash (-) operator. The dash operator enables you to list variables that are numbered sequentially, and the colon operator selects all variables with a given prefix. For example, if your data set contains the variables X1 through X9, the following MODEL statements are equivalent:

model Y = X1 X2 X3 X4 X5 X6 X7 X8 X9;

model Y = X1-X9;

model Y = X:;

If your data set contains only the three covariates X1, X2, and X9, then the colon operator selects all three variables:

model Y = X:;

However, the following specification returns an error because X3 through X8 are not in the data set:

model Y = X1-X9;

The double dash (- -) operator enables you to select variables that are stored sequentially in the SAS data set, whether or not they have a common prefix. You can use the CONTENTS procedure (see Base SAS Procedures Guide) to determine your variable ordering. For example, if you replace the dash in the preceding MODEL statement with a double dash, as follows, then all three variables are selected:

model Y = X1--X9;

If your data set contains the variables A, B, and C, then you can use the double dash operator to select these variables by specifying the following:

model Y = A--C;
Last updated: July 09, 2026