s (substitution) processing code

The s processing code substitutes either a data value from the referenced attribute or literal text when the current data value is null or zero.

System Processors Select, Update, List
Code Type Attribute Defining
Dictionary Attributes Input Conversion, Output Conversion, Correlative

Syntax

s;attrnum1|text|*;attrnum2|text

Parameter(s)

attrnum1 Value to substitute if the attribute value tested is not null or zero. Can be an attribute number or literal text enclosed in single quotes.
attrnum2 Value to substitute if the attribute value tested is null. Can be an attribute number or literal text enclosed in single quotes.
text Contains the literal text string.
* Displays the original data value, if it is not null or 0; otherwise, the second argument displays. This feature can be used as the first parameter of an f processing code in the form:
fattrnum(s;*;’text’)

The asterisk can also be embedded within an a processing code. Substitution is used in an a (algebraic) processing code as an alternative to the then/else construct.

Description

The s processing code returns the value defined by attribute number 2 if the value for conversion is null or 0; otherwise, the value of attribute number 1 is returned. Both attribute number 1 and attribute number 2 can be an attribute number or text string.

Example(s)

These a-correlatives produce identical results:

aif n(sales)>="1000000" then "made it" else "trouble"

a(n(sales)>="1000000")(s;"made it";"trouble")

The following checks for the existence of a shipping address in attribute 20. If not there, show the billing address in attribute 10.

a(20)(S;*;10)