in range…for selects from a list of attributes or groups whose values are within a specified range, provided that the condition specified by the ‘for’ expression is true.
The syntax is:
{ names } in range [lower, upper] for (expression)
where:
names is a comma separated list of attribute or group attribute names,
lower and upper are numbers or constants defining the range, and
expression is the condition that must also be satisfied.
A typical use of this function would be to create an age-dependent calculated value attribute. For example, you could define a calculated value attributeĀ HighAllergensForInfants as:
{birch, timothy, cat} in range [20, 50] for (age < 2)
and the case would then appear as:
age 1 sex F birch 50.0 timothy 63.5 cat 64.6 HighAllergensForInfants cat (64.6), timothy (63.5) and birch (50.0)
A comment could now be created that used the expression HighAllergensForInfants to list the allergens in the range [20,50]. For a case where the age was greater than 2, HighAllergensForInfants would be empty. Similarly, we could define another calculated value attribute for people aged two or more as:
{birch, timothy, cat} in range (50, 100] for (age >= 2)
We could combine these two expressions into a single expression covering all ages using the union
syntax as follows:
{birch, timothy, cat} in range [20, 50] for (age < 2) union {birch, timothy, cat} in range (50, 100] for (age >= 2)
Note: The syntax in range…for is actually a combination of the in range and the for functions.
See also: