Editing a Data Expression in Text Mode

Overview of Text Mode

In SAS Visual Analytics, you create and edit filters, calculated items, and aggregated items by using an expression editor. The Text tab of the expression editor enables you to edit the expression as text.
You can add operators and data items to your expression by dragging and dropping them onto the expression or by entering the names of the operators or data items.
As you enter text, a list of suggestions appears. For example, if you enter date, then a drop-down list appears and enables you to select any of the operators and data items whose names begin with “date.”
When you make changes to your expression, it is automatically evaluated to determine whether it is valid. If the expression is not valid, then an error appears on the Messages tab, and the OK button is disabled. There might be a brief delay as your expression is evaluated.

Specifying Operator Parameters

When you add an operator to the expression, any parameters that are required by the operator are represented between braces { }. For example, if you add the x – y operator, then your expression appears as {Number} — {Number}.
Each parameter value that you enter should replace the entire string between the braces, including the brace characters. For example, you might replace {Number} with 12 or with a data item such as Expenses.
You can automatically select the next operator in the expression by pressing Ctrl + Shift + spacebar.

Specifying Data Items

Data item names can be entered as plain text and are not case sensitive. You can enter data item names formally by using the format 'data-item-name'n. If you switch to the Visual tab, then all of your data item names are converted to the formal format.
Note: If a data item name contains quotation marks, then you must use the \ character to escape the quotes.
Note: If a data item name contains spaces, then you must use the formal format.
Note: If a data item has the same name as an operator, then you must use the formal format. For example, if you have a category named Year, then enter the name as 'Year'n to avoid conflict with the Year operator.

Using Formatted and Unformatted Values

By default, category values and discrete numeric and date values are evaluated as formatted values. Continuous numeric values are evaluated as unformatted values.
To override this default behavior, you can add [raw] (to use unformatted values) or [formatted] (to use formatted values) to the right of the data item.
For example,
'Expenses'n[formatted]
specifies that the Expenses measure is evaluated as a formatted value.

Specifying String Values

To enter a string value, you can enter the string between single quotes or double quotes. If your value contains a quotation mark, use the \ character to escape the quote. If you use double quotes to enclose the string, then you do not need to escape the single quotes. If you use single quotes to enclose the string, then you do not need to escape the double quotes. For example, "O'Reilly", 'O\'Reilly', and '"Hello"' are all valid.
To enter a string that contains a newline character, use \r, \n, or both to specify the newline character.

Specifying Date, Time, and Datetime Values

For date, datetime, and time values, specify a formatted value in quotes, followed by the letter “d” for a date value, the letters “dt” for a datetime value, or the letter “t” for a time value.
For time values, a value with a leading underscore is a reference to a specific time of the day.
A time value without a leading underscore specifies a period of elapsed time.
Here are some examples of date, datetime, and time values:
Example Date, Datetime, and Time Values
Date
'23JUN2013'd
'JUN2013'd
'2013'd
'q32013'd
Datetime
'23JUN2013_5:23:55’dt
'23JUN2013_5:23'dt
'23JUN2013'dt
Time
'_12:23:55't
'_12:23't
Elapsed Time
'44:23:55't
'00:01:34't

Specifying Aggregated Values

For aggregated values, specify the format, aggregation-type [context] (value), where context specifies one of the following aggregation contexts:
ByGroup
calculates the aggregation for each subset of the data item that is used in a visualization. For example, in a bar chart, an aggregated measure with the ByGroup context calculates a separate aggregated value for each bar in the chart.
ForAll
calculates the aggregation for the entire data item (after filtering). For example, in a bar chart, an aggregated measure with the ForAll context uses the same aggregated value (calculated for the entire data item) for each bar in the chart.
See Aggregated Operators for a list of the aggregation types that are available.
For example,
sum [bygroup] ('cost'n)
aggregates the sum of the measure COST for each BY-group value.

Specifying a Missing Value

Use a period character (.) to specify a missing numeric or date value. Use empty quotes ('') to specify a missing string value.