Flow to stock: flow_to_stock
Syntax
flow_to_stock ( op )
Input parameters
op |
the operand |
Examples of valid syntaxes
flow_to_stock ( ds_1 )
Semantics for scalar operations
This operator does not perform scalar operations.
Input parameters type
op
dataset { identifier < time > _ , identifier _* , measure<number> _+ }
Result type
result
dataset { identifier < time > _ , identifier _* , measure<number> _+ }
Additional Constraints
The operand dataset has an Identifier of type time, date or time_period and may have other Identifiers.
Behavior
The statistical data that describe the “state” of a phenomenon on a given moment (e.g. resident population on a given moment) are often referred to as “stock data”.
On the contrary, the statistical data that describe “events” which can happen continuously (e.g. changes in the resident population, such as births, deaths, immigration, emigration), are often referred to as “flow data”.
This operator takes in input a Data Set which are interpreted as flows and calculates the change of the corresponding stock since the beginning of each time series by summing the relevant flows. In other words, the operator perform the cumulative sum from the first Data Point of each time series to each other following Data Point of the same time series.
The flow_to_stock operator can be applied only on Data Sets of time series and returns a Data Set of time series.
The result Data Set has the same Identifier, Measure and Attribute Components as the operand Data Set and contains the same time series as the operand, because the time series Identifiers (all the Identifiers except the reference time Identifier) are not changed.
As mentioned in the section “Behaviour of the Time Operators”, the operator is assumed to know which is the time Identifier as well as the period of each time series.
Examples
As described in the User Manual, the time data type is the intervening time between two time points and using the ISO 8601 standard it can be expressed through a start date and an end date separated by a slash at any precision. In the examples relevant to the time data type the precision is set at the level of month and the time format YYYY-MM/YYYY-MM is used.
Given:
The operand dataset DS_1, which contains annual time series, where Id_2 is the reference time Identifier of time type;
the operand dataset DS_2, which contains annual time series, where Id_2 is the reference time Identifier of date type (conventionally each period is identified by its last day);
the operand dataset DS_3, which contains annual time series, where Id_2 is the reference time Identifier of time_period type;
the operand dataset DS_4, which contains both quarterly and annual time series relevant to the same phenomenon “A”, where Id_2 is the reference time Identifier of time_period type:
Input DS_1 (see structure)
Id_1 |
Id_2 |
Me_1 |
---|---|---|
A |
2010M1/2010M12 |
2.0 |
A |
2011M1/2011M12 |
5.0 |
A |
2012M1/2012M12 |
-3.0 |
A |
2013M1/2013M12 |
9.0 |
B |
2010M1/2010M12 |
4.0 |
B |
2011M1/2011M12 |
-8.0 |
B |
2012M1/2012M12 |
0.0 |
B |
2013M1/2013M12 |
6.0 |
Input DS_2 (see structure)
Id_1 |
Id_2 |
Me_1 |
---|---|---|
A |
2010-12-31 |
2.0 |
A |
2011-12-31 |
5.0 |
A |
2012-12-31 |
-3.0 |
A |
9999-12-31 |
9.0 |
B |
2010-12-31 |
4.0 |
B |
2011-12-31 |
-8.0 |
B |
2012-12-31 |
0.0 |
B |
9999-12-31 |
6.0 |
Input DS_3 (see structure)
Id_1 |
Id_2 |
Me_1 |
---|---|---|
A |
2010 |
2.0 |
A |
2011 |
5.0 |
A |
2012 |
-3.0 |
A |
2013 |
9.0 |
B |
2010 |
4.0 |
B |
2011 |
-8.0 |
B |
2012 |
0.0 |
B |
2013 |
6.0 |
Input DS_4 (see structure)
Id_1 |
Id_2 |
Me_1 |
---|---|---|
A |
2010 |
2.0 |
A |
2011 |
7.0 |
A |
2012 |
4.0 |
A |
2013 |
13.0 |
A |
2010Q1 |
2.0 |
A |
2010Q2 |
-3.0 |
A |
2010Q3 |
7.0 |
A |
2010Q4 |
-4.0 |
Example 1
DS_r := flow_to_stock ( DS_1 );
results in (see structure):
Id_1 |
Id_2 |
Me_1 |
---|---|---|
A |
2010M1/2010M12 |
2.0 |
A |
2011M1/2011M12 |
7.0 |
A |
2012M1/2012M12 |
4.0 |
A |
2013M1/2013M12 |
13.0 |
B |
2010M1/2010M12 |
4.0 |
B |
2011M1/2011M12 |
-4.0 |
B |
2012M1/2012M12 |
-4.0 |
B |
2013M1/2013M12 |
2.0 |
Example 2
DS_r := flow_to_stock ( DS_2 );
results in (see structure):
Id_1 |
Id_2 |
Me_1 |
---|---|---|
A |
2010-12-31 |
2.0 |
A |
2011-12-31 |
7.0 |
A |
2012-12-31 |
4.0 |
A |
9999-12-31 |
13.0 |
B |
2010-12-31 |
4.0 |
B |
2011-12-31 |
-4.0 |
B |
2012-12-31 |
-4.0 |
B |
9999-12-31 |
2.0 |
Example 3
DS_r := flow_to_stock ( DS_3 );
results in (see structure):
Id_1 |
Id_2 |
Me_1 |
---|---|---|
A |
2010 |
2.0 |
A |
2011 |
7.0 |
A |
2012 |
4.0 |
A |
2013 |
13.0 |
B |
2010 |
4.0 |
B |
2011 |
-4.0 |
B |
2012 |
-4.0 |
B |
2013 |
2.0 |
Example 4
DS_r := flow_to_stock ( DS_4 );
results in (see structure):
Id_1 |
Id_2 |
Me_1 |
---|---|---|
A |
2010 |
2.0 |
A |
2011 |
9.0 |
A |
2012 |
13.0 |
A |
2013 |
26.0 |
A |
2010-Q1 |
2.0 |
A |
2010-Q2 |
-1.0 |
A |
2010-Q3 |
6.0 |
A |
2010-Q4 |
2.0 |