Exists in: exists_in

Syntax

exists_in ( op1, op2 { , retain } )

retain ::= true | false | all

Input parameters

op1

the operand dataset

op2

the operand dataset

retain

the optional parameter to specify the Data Points to be returned (default: all)

Examples of valid syntaxes

exists_in(DS_1, DS_2, true)
exists_in(DS_1, DS_2)
exists_in(DS_1, DS_2, all)

Semantics for scalar operations

This operator cannot be applied to scalar values.

Input parameters type

op1, op2

dataset

Result type

result

dataset { measure<boolean> bool_var }

Additional Constraints

op1 has at least all the identifier components of op2 or op2 has at least all the identifier components of op1.

Behaviour

The operator takes under consideration the common Identifiers of op1 and op2 and checks if the combinations of values of these Identifiers which are in op1 also exist in op2.

The result has the same Identifiers as op1 and a boolean Measure bool_var whose value, for each Data Point of op1, is TRUE if the combination of values of the common Identifier Components in op1 is found in a Data Point of op2, FALSE otherwise.

If retain is all then both the Data Points having bool_var = TRUE and bool_var = FALSE are returned.

If retain is true then only the data points with bool_var = TRUE are returned.

If retain is false then only the Data Points with bool_var = FALSE are returned.

If the retain parameter is omitted, the default is all.

The operator has the typical behaviour of the “Operators changing the data type” (see the section “Typical behaviours of the ML Operators”).

Examples

Given the operand datasets DS_1 and DS_2:

Input DS_1 (see structure)

Id_1

Id_2

Id_3

Id_4

Me_1

2012

B

Total

Total

11094850

2012

G

Total

Total

11123034

2012

S

Total

Total

46818219

2012

M

Total

Total

417546

2012

F

Total

Total

5401267

2012

W

Total

Total

7954662

Input DS_2 (see structure)

Id_1

Id_2

Id_3

Id_4

Me_1

2012

B

Total

Total

0.023

2012

G

Total

M

0.286

2012

S

Total

Total

0.064

2012

M

Total

M

0.043

2012

F

Total

Total

2012

W

Total

Total

0.08

Example 1

DS_r := exists_in (DS_1, DS_2, all);

results in (see structure):

DS_r

Id_1

Id_2

Id_3

Id_4

bool_var

2012

B

Total

Total

True

2012

G

Total

Total

False

2012

S

Total

Total

True

2012

M

Total

Total

False

2012

F

Total

Total

True

2012

W

Total

Total

True

Example 2

DS_r := exists_in (DS_1, DS_2, true);

results in (see structure):

DS_r

Id_1

Id_2

Id_3

Id_4

bool_var

2012

B

Total

Total

True

2012

S

Total

Total

True

2012

F

Total

Total

True

2012

W

Total

Total

True

Example 3

DS_r := exists_in (DS_1, DS_2, false);

results in (see structure):

DS_r

Id_1

Id_2

Id_3

Id_4

bool_var

2012

G

Total

Total

False

2012

M

Total

Total

False