Values and data types

CLEM expressions are similar to formulas constructed from values, field names, operators, and functions. The simplest valid CLEM expression is a value or a field name.

Examples of valid values are:

3
1.79
'banana'

Examples of field names are:

Product_ID
'$P-NextField'

where Product is the name of a field from a market basket data set, '$P-NextField' is the name of a parameter, and the value of the expression is the value of the named field. Typically, field names start with a letter and may also contain digits and underscores (_). You can use names that don't follow these rules if you place the name within quotation marks. CLEM values can be any of the following:

  • Strings (for example, "c1", "Type 2", "a piece of free text")
  • Integers (for example, 12, 0, –189)
  • Real numbers (for example, 12.34, 0.0, –0.0045)
  • Date/time fields (for example, 05/12/2002, 12/05/2002, 12/05/02)

It's also possible to use the following elements:

  • Character codes (for example, `a` or 3)
  • Lists of items (for example, [1 2 3], ['Type 1' 'Type 2'])

Character codes and lists don't usually occur as field values. Typically, they're used as arguments of CLEM functions.

Quoting rules

Although the software is flexible when determining the fields, values, parameters, and strings used in a CLEM expression, the following general rules provide a list of best practices to use when creating expressions:

  • Strings: Always use double quotes when writing strings ("Type 2" or "value"). Single quotes can be used instead but at the risk of confusion with quoted fields.
  • Characters: Always use single backquotes like `. For example, note the character d in the function stripchar(`d`,"drugA"). The only exception to this is when you're using an integer to refer to a specific character in a string. For example, note the character 5 in the function lowertoupper("druga"(5)) —> "A".
  • Fields: Fields are typically unquoted when used in CLEM expressions (subscr(2,arrayID)) —> CHAR). You can use single quotes when necessary to enclose spaces or other special characters ('Order Number'). Fields that are quoted but undefined in the data set will be misread as strings.
  • Parameters: Always use single quotes ('$P-threshold').