Set difference: setdiff
Syntax
setdiff ( ds1, ds2 )
Input parameters
ds1 |
the first Data Set in the difference (the minuend) |
ds2 |
the second Data Set in the difference (the subtrahend) |
Examples of valid syntaxes
setdiff (ds2, ds3)
Semantics for scalar operations
This operator cannot be applied to scalar values.
Input parameters type
ds1, ds2
dataset
Result type
result
dataset
Additional Constraints
The operand Data Sets have the same Identifier, Measure and Attribute Components.
Behavior
The operator implements the set difference of functions (i.e. Data Sets), interpreting the Data Points of the input Data Sets as the elements belonging to the operand sets, the minuend and the subtrahend, respectively. The operator returns one single Data Set, with the same Identifier, Measure and Attribute Components as the operand Data Sets, containing the Data Points that appear in the first Data Set but not in the second. In other words, for setdiff (ds1, ds2), the resulting Dataset contains all the data points Data Point dp1 of the operand ds1, such that there is no Data Point dp2 of ds2 having the same values for homonym Identifier Components.
The operator has the typical behaviour of the “Behaviour of the Set operators” (see the section “Typical behaviours of the ML Operators”).
The automatic Attribute propagation is not applied.
Examples
Given the operand datasets DS_1, DS_2, DS_3 and DS_4:
Input DS_1 (see structure)
Id_1 |
Id_2 |
Id_3 |
Id_4 |
Me_1 |
---|---|---|---|---|
2012 |
B |
Total |
Total |
10 |
2012 |
G |
Total |
Total |
20 |
2012 |
F |
Total |
Total |
30 |
2012 |
M |
Total |
Total |
40 |
2012 |
I |
Total |
Total |
50 |
2012 |
S |
Total |
Total |
60 |
Input DS_2 (see structure)
Id_1 |
Id_2 |
Id_3 |
Id_4 |
Me_1 |
---|---|---|---|---|
2011 |
B |
Total |
Total |
10 |
2012 |
G |
Total |
Total |
20 |
2012 |
F |
Total |
Total |
30 |
2012 |
M |
Total |
Total |
40 |
2012 |
I |
Total |
Total |
50 |
2012 |
S |
Total |
Total |
60 |
Input DS_3 (see structure)
Id_1 |
Id_2 |
Id_3 |
Me_1 |
---|---|---|---|
R |
M |
2011 |
7 |
R |
F |
2011 |
10 |
R |
T |
2011 |
12 |
Input DS_4 (see structure)
Id_1 |
Id_2 |
Id_3 |
Me_1 |
---|---|---|---|
R |
M |
2011 |
7 |
R |
F |
2011 |
10 |
Example 1
DS_r := setdiff ( DS_1, DS_2 );
results in (see structure):
Id_1 |
Id_2 |
Id_3 |
Id_4 |
Me_1 |
---|---|---|---|---|
2012 |
B |
Total |
Total |
10.0 |
Example 2
DS_r := setdiff ( DS_3, DS_4 );
results in (see structure):
Id_1 |
Id_2 |
Id_3 |
Me_1 |
---|---|---|---|
R |
T |
2011 |
12 |