Wiki source code of 13 Structure Mapping

Last modified by Artur on 2025/09/10 11:19

Show last authors
1 {{box title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 == 13.1 Introduction ==
6
7 The purpose of [[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] structure mapping is to transform [[datasets>>doc:sdmx:Glossary.Data set.WebHome]] from one dimensionality to another. In practice, this means that the input and output [[datasets>>doc:sdmx:Glossary.Data set.WebHome]] conform to different Data Structure Definition.
8
9 Structure mapping does not alter the [[observation values>>doc:sdmx:Glossary.Observation value.WebHome]] and is not intended to perform any aggregations or calculations.
10
11 An input series maps to:
12
13 1. Exactly one output series; or
14 1. Multiple output series with different [[Series Keys>>doc:sdmx:Glossary.Series key.WebHome]], but the same [[observation values>>doc:sdmx:Glossary.Observation value.WebHome]]; or
15 1. Zero output series where no source rule matches the input [[Component>>doc:sdmx:Glossary.Component.WebHome]] values.
16
17 Typical use cases include:
18
19 * Transforming received data into a common internal structure;
20 * Transforming reported data into the data collector's preferred structure;
21 * Transforming unidimensional [[datasets>>doc:sdmx:Glossary.Data set.WebHome]]{{footnote}}Unidimensional datasets are those with a single 'indicator' or 'series code' dimension.{{/footnote}}^^{{footnote}}Unidimensional datasets are those with a single 'indicator' or 'series code' dimension.{{/footnote}}^^ to multi-dimensional; and
22 * Transforming internal [[datasets>>doc:sdmx:Glossary.Data set.WebHome]] with a complex structure to a simpler structure with fewer [[dimensions>>doc:sdmx:Glossary.Dimension.WebHome]] suitable for dissemination.
23
24 == 13.2 1-1 structure maps ==
25
26 1-1 (pronounced 'one to one') mappings support the simple use case where the value of a [[Component>>doc:sdmx:Glossary.Component.WebHome]] in the source structure is translated to a different value in the target, usually where different classification schemes are used for the same Concept.
27
28 In the example below, ISO 2-character country [[codes>>doc:sdmx:Glossary.Code.WebHome]] are mapped to their ISO 3character equivalent.
29
30 (% style="width:585.294px" %)
31 |(% style="width:173px" %)**Country**|(% style="width:180px" %)**Alpha-2 code**|(% style="width:229px" %)**Alpha-3 code**
32 |(% style="width:173px" %)Afghanistan|(% style="width:180px" %)AF|(% style="width:229px" %)AFG
33 |(% style="width:173px" %)Albania|(% style="width:180px" %)AL|(% style="width:229px" %)ALB
34 |(% style="width:173px" %)Algeria|(% style="width:180px" %)DZ|(% style="width:229px" %)DZA
35 |(% style="width:173px" %)American Samoa|(% style="width:180px" %)AS|(% style="width:229px" %)ASM
36 |(% style="width:173px" %)Andorra|(% style="width:180px" %)AD|(% style="width:229px" %)AND
37 |(% style="width:173px" %)etc…|(% style="width:180px" %) |(% style="width:229px" %)
38
39 Different source values can also map to the same target value, for example when deriving regions from country [[codes>>doc:sdmx:Glossary.Code.WebHome]].
40
41 (% style="width:490.294px" %)
42 |(% style="width:260px" %)Source Component: REF_AREA|(% style="width:227px" %)Target Component: REGION
43 |(% style="width:260px" %)FR|(% style="width:227px" %)EUR
44 |(% style="width:260px" %)DE|(% style="width:227px" %)EUR
45 |(% style="width:260px" %)IT|(% style="width:227px" %)EUR
46 |(% style="width:260px" %)ES|(% style="width:227px" %)EUR
47 |(% style="width:260px" %)BE|(% style="width:227px" %)EUR
48
49 == 13.3 N-n structure maps ==
50
51 N-n (pronounced 'N to N') mappings describe rules where a specified combination of values in multiple source [[Components>>doc:sdmx:Glossary.Component.WebHome]] map to specified values in one or more target [[Components>>doc:sdmx:Glossary.Component.WebHome]]. For example, when mapping a partial [[Series Key>>doc:sdmx:Glossary.Series key.WebHome]] from a highly multidimensional cube (like Balance of Payments) to a single 'Indicator' [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]] in a target Data Structure.
52
53 Example:
54
55 (% style="width:964.294px" %)
56 |(% style="width:65px" %)Rule|(% style="width:519px" %)Source|(% style="width:378px" %)Target
57 |(% style="width:65px" %)1|(% style="width:519px" %)(((
58 If
59 FREQUENCY=A; and
60 ADJUSTMENT=N; and
61 MATURITY=L.
62 )))|(% style="width:378px" %)(((
63 Set
64 INDICATOR=A_N_L
65 )))
66 |(% style="width:65px" %)2|(% style="width:519px" %)(((
67 If
68 FREQUENCY=M; and
69 ADJUSTMENT=S_A1; and
70 MATURITY=TY12.
71 )))|(% style="width:378px" %)(((
72 Set
73 INDICATOR=MON_SAX_12
74 )))
75
76 N-n rules can also set values for multiple source Components.
77
78 (% style="width:965.294px" %)
79 |(% style="width:73px" %)Rule|(% style="width:506px" %)Source|(% style="width:383px" %)Target
80 |(% style="width:73px" %)1|(% style="width:506px" %)(((
81 If
82 FREQUENCY=A; and ADJUSTMENT=N; and MATURITY=L.
83 )))|(% style="width:383px" %)(((
84 Set
85 INDICATOR=A_N_L, STATUS=QXR15,
86 NOTE="Unadjusted".
87 )))
88 |(% style="width:73px" %)2|(% style="width:506px" %)(((
89 If
90 FREQUENCY=M; and ADJUSTMENT=S_A1; and MATURITY=TY12.
91 )))|(% style="width:383px" %)(((
92 Set
93 INDICATOR=MON_SAX_12,
94 STATUS=MPM12,
95 NOTE="Seasonally Adjusted"
96 )))
97
98 == 13.4 Ambiguous mapping rules ==
99
100 A structure map is ambiguous if the rules result in a dataset containing multiple series with the same Series Key.
101
102 A simple example mapping a source dataset with a single dimension to one with multiple dimensions is shown below:
103
104 (% style="width:972.294px" %)
105 |(% style="width:257px" %)Source|(% style="width:315px" %)Target|(% style="width:397px" %)Output Series Key
106 |(% style="width:257px" %)SERIES_CODE=XMAN_Z_21|(% style="width:315px" %)(((
107 Dimensions
108 INDICATOR=XM
109 FREQ=A
110 ADJUSTMENT=N
111 Attributes
112 UNIT_MEASURE=_Z
113 COMP_ORG=21
114 )))|(% style="width:397px" %)XM:A:N
115 |(% style="width:257px" %)(((
116 SERIES_CODE=XMAN_Z_34
117
118
119 )))|(% style="width:315px" %)(((
120 Dimensions
121 INDICATOR=XM
122 FREQ=A
123 ADJUSTMENT=N
124 Attributes
125 UNIT_MEASURE=_Z
126 COMP_ORG=34
127 )))|(% style="width:397px" %)XM:A:N
128
129 The above behaviour can be okay if the series XMAN_Z_21 contains observations for different periods of time then the series XMAN_Z_34. If however both series contain observations for the same point in time, the output for this mapping will be two observations with the same [[series key>>doc:sdmx:Glossary.Series key.WebHome]], for the same period in time.
130
131 == 13.5 Representation maps ==
132
133 [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Maps replace the [[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] 2.1 Codelist Maps and are used describe explicit mappings between source and target [[Component>>doc:sdmx:Glossary.Component.WebHome]] values.
134
135 The source and target of a [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Map can reference any of the following:
136
137 1. Codelist
138 1. Free Text (restricted by type, e.g String, Integer, Boolean)
139 1. Valuelist
140
141 A [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Map mapping ISO 2-character to ISO 3-character Codelists would take the following form:
142
143 (% style="width:356.294px" %)
144 |(% style="width:167px" %)CL_ISO_ALPHA2|(% style="width:186px" %)CL_ISO_ALPHA3
145 |(% style="width:167px" %)AF|(% style="width:186px" %)AFG
146 |(% style="width:167px" %)AL|(% style="width:186px" %)ALB
147 |(% style="width:167px" %)DZ|(% style="width:186px" %)DZA
148 |(% style="width:167px" %)AS|(% style="width:186px" %)ASM
149 |(% style="width:167px" %)AD|(% style="width:186px" %)AND
150 |(% style="width:167px" %)etc…|(% style="width:186px" %)
151
152 A [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Map mapping free text country names to an ISO 2-character Codelist could be similarly described:
153
154 (% style="width:364.294px" %)
155 |(% style="width:169px" %)Text|(% style="width:192px" %)CL_ISO_ALPHA2
156 |(% style="width:169px" %)"Germany"|(% style="width:192px" %)DE
157 |(% style="width:169px" %)"France"|(% style="width:192px" %)FR
158 |(% style="width:169px" %)"United Kingdom"|(% style="width:192px" %)GB
159 |(% style="width:169px" %)"Great Britain"|(% style="width:192px" %)GB
160 |(% style="width:169px" %)"Ireland"|(% style="width:192px" %)IE
161 |(% style="width:169px" %)"Eire"|(% style="width:192px" %)IE
162 |(% style="width:169px" %)etc…|(% style="width:192px" %)
163
164 Valuelists, introduced in [[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] 3.0, are equivalent to Codelists but allow the maintenance of non-[[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] identifiers. Importantly, their IDs do not need to conform to IDType, but as a consequence are not Identifiable.
165
166 When used in [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Maps, Valuelists allow Non-[[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] identifiers containing characters like £, $, % to be mapped to [[Code>>doc:sdmx:Glossary.Code.WebHome]] IDs, or [[Codes>>doc:sdmx:Glossary.Code.WebHome]] mapped to non-[[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] identifiers.
167
168 In common with Codelists, each item in a Valuelist has a multilingual name giving it a human-readable label and an optional description. For example:
169
170 (% style="width:435.294px" %)
171 |(% style="width:126px" %)Value|(% style="width:133px" %)Locale|(% style="width:173px" %)Name
172 |(% style="width:126px" %)$|(% style="width:133px" %)en|(% style="width:173px" %)United States Dollar
173 |(% style="width:126px" %)%|(% style="width:133px" %)En|(% style="width:173px" %)Percentage
174 |(% style="width:126px" %) |(% style="width:133px" %)fr|(% style="width:173px" %)Pourcentage
175
176 Other characteristics of [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Maps:
177
178 * Support the mapping of multiple source [[Component>>doc:sdmx:Glossary.Component.WebHome]] values to multiple Target [[Component>>doc:sdmx:Glossary.Component.WebHome]] values as described in section 13.3 on n-to-n mappings; this covers also the case of mapping an [[Attribute>>doc:sdmx:Glossary.Attribute.WebHome]] with an array [[representation>>doc:sdmx:Glossary.Representation.WebHome]] to map combinations of values to a single target value;
179 * Allow source or target mappings for an Item to be optional allowing rules such as 'A maps to nothing' or 'nothing maps to A'; and
180 * Support for mapping rules where regular expressions or substrings are used to match source [[Component>>doc:sdmx:Glossary.Component.WebHome]] values. Refer to section 13.6 for more on this topic.
181
182 == 13.6 Regular expression and substring rules ==
183
184 It is common for classifications to contain meanings within the identifier, for example the [[code>>doc:sdmx:Glossary.Code.WebHome]] Id 'XULADS' may refer to a particular seasonality because it starts with the letters XU.
185
186 With [[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] 2.1 each [[code>>doc:sdmx:Glossary.Code.WebHome]] that starts with XU had to be individually mapped to the same seasonality, and additional mappings added when new [[Codes>>doc:sdmx:Glossary.Code.WebHome]] were added to the Codelists. This led to many hundreds or thousands of mappings which can be more efficiently summarised in a single conceptual rule:
187
188 //If starts with 'XU' map to 'Y'//
189
190 These rules are described using either regular expressions, or substrings for simpler use cases.
191
192 === 13.6.1 Regular expressions ===
193
194 Regular expression mapping rules are defined in the [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Map.
195
196 Below is an example set of regular expression rules for a particular [[component>>doc:sdmx:Glossary.Component.WebHome]].
197
198 (% style="width:664.294px" %)
199 |(% style="width:141px" %)**Regex**|(% style="width:362px" %)**Description**|(% style="width:158px" %)**Output**
200 |(% style="width:141px" %)A|(% style="width:362px" %)Rule match if input = 'A'|(% style="width:158px" %)OUT_A
201 |(% style="width:141px" %)^[A-G]|(% style="width:362px" %)Rule match if the input starts with letters A to G|(% style="width:158px" %)OUT_B
202 |(% style="width:141px" %)A~|B|(% style="width:362px" %)Rule match if input is either 'A' or 'B'|(% style="width:158px" %)OUT_C
203
204 Like all mapping rules, the output is either a [[Code>>doc:sdmx:Glossary.Code.WebHome]], a Value or free text depending on the [[representation>>doc:sdmx:Glossary.Representation.WebHome]] of the [[Component>>doc:sdmx:Glossary.Component.WebHome]] in the target [[Data Structure Definition>>doc:sdmx:Glossary.Data structure definition.WebHome]].
205
206 If the regular expression contains capture groups, these can be used in the definition of the output value, by specifying \**//n//**// //as an output value where **//n//** is the number of the capture group starting from 1. For example
207
208 (% style="width:700.294px" %)
209 |(% style="width:203px" %)Regex|(% style="width:148px" %)Target output|(% style="width:157px" %)Example Input|(% style="width:189px" %)Example Output
210 |(% style="width:203px" %)(((
211 ([0-9]{4})[0-9]([0-9]{1})
212 )))|(% style="width:148px" %)\1-Q\2|(% style="width:157px" %)200933|(% style="width:189px" %)2009-Q3
213
214 As regular expression rules can be used as a general catch-all if nothing else matches, the ordering of the rules is important. Rules should be tested starting with the highest priority, moving down the list until a match is found.
215
216 The following example shows this:
217
218 (% style="width:704.294px" %)
219 |(% style="width:130px" %)Priority|(% style="width:125px" %)Regex|(% style="width:241px" %)Description|(% style="width:205px" %)Output
220 |(% style="width:130px" %)1|(% style="width:125px" %)A|(% style="width:241px" %)Rule match if input = 'A'|(% style="width:205px" %)OUT_A
221 |(% style="width:130px" %)2|(% style="width:125px" %)B|(% style="width:241px" %)Rule match if input = 'B'|(% style="width:205px" %)OUT_B
222 |(% style="width:130px" %)3|(% style="width:125px" %)[A-Z]|(% style="width:241px" %)Any character A-Z|(% style="width:205px" %)OUT_C
223
224 The input 'A' matches both the first and the last rule, but the first takes precedence having the higher priority. The output is OUT_A.
225
226 The input 'G' matches on the last rule which is used as a catch-all or default in this example.
227
228 === 13.6.2 Substrings ===
229
230 Substrings provide an alternative to regular expressions where the required section of an input value can be described using the number of the starting character, and the length of the substring in characters. The first character is at position 1.
231
232 For instance:
233
234 (% style="width:623.294px" %)
235 |(% style="width:169px" %)Input String|(% style="width:147px" %)Start|(% style="width:133px" %)Length|(% style="width:171px" %)Output
236 |(% style="width:169px" %)ABC_DEF_XYZ|(% style="width:147px" %)5|(% style="width:133px" %)3|(% style="width:171px" %)DEF
237 |(% style="width:169px" %)XULADS|(% style="width:147px" %)1|(% style="width:133px" %)2|(% style="width:171px" %)XU
238
239 Sub-strings can therefore be used for the conceptual rule //If starts with 'XU' map to Y// as shown in the following example:
240
241 (% style="width:628.294px" %)
242 |(% style="width:163px" %)Start|(% style="width:158px" %)Length|(% style="width:128px" %)Source|(% style="width:176px" %)Target
243 |(% style="width:163px" %)1|(% style="width:158px" %)2|(% style="width:128px" %)XU|(% style="width:176px" %)Y
244
245 == 13.7 Mapping non-SDMX time formats to SDMX formats ==
246
247 Structure mapping allows non-[[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] compliant time values in source [[datasets>>doc:sdmx:Glossary.Data set.WebHome]] to be mapped to an [[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] compliant time format.
248
249 Two types of time input are defined:
250
251 a. **Pattern based dates** – a string which can be described using a notation like dd/mm/yyyy or is represented as the number of periods since a point in time, for example: 2010M001 (first month in 2010), or 2014D123 (123^^rd^^ day in 2014); and
252 b. **Numerical based datetime** – a number specifying the elapsed periods since a fixed point in time, for example Unix Time is measured by the number of milliseconds since 1970.
253
254 The output of a time-based mapping is derived from the output Frequency, which is either explicitly stated in the mapping or defined as the value output by a specific [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]] or [[Attribute>>doc:sdmx:Glossary.Attribute.WebHome]] in the output mapping. If the output frequency is unknown or if the [[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] format is not desired, then additional rules can be provided to specify the output date format for the given frequency Id. The default rules are:
255
256 |Frequency|Format|Example
257 |A|YYYY|2010
258 |D|YYYY-MM-DD|2010-01-01
259 |I|(((
260 YYYY-MM-DD-
261
262 Thh:mm:ss
263 )))|2010-01T20:22:00
264 |M|YYYY-MM|2010-01
265 |Q|YYYY-Qn|2010-Q1
266 |S|YYYY-Sn|2010-S1
267 |T|YYYY-Tn|2010-T1
268 |W|YYYY-Wn|YYYY-W53
269
270 In the case where the input frequency is lower than the output frequency, the mapping defaults to end of period, but can be explicitly set to start, end or mid-period.
271
272 There are two important points to note:
273
274 1. The output frequency determines the output date format, but the default output can be redefined using a Frequency Format mapping to force explicit rules on how the output [[time period>>doc:sdmx:Glossary.Time period.WebHome]] is formatted.
275 1. To support the use case of changing frequency the structure map can optionally provide a start of year [[attribute>>doc:sdmx:Glossary.Attribute.WebHome]], which defines the year start date in MM-DD format. For example: YearStart=04-01.
276
277 === 13.7.1 Pattern based dates ===
278
279 Date and [[time formats>>doc:sdmx:Glossary.Time format.WebHome]] are specified by date and time pattern strings based on Java's Simple Date Format. Within date and time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the [[components>>doc:sdmx:Glossary.Component.WebHome]] of a date or time string. Text can be quoted using single quotes (') to avoid interpretation. "''" represents a single quote. All other characters are not interpreted; they're simply copied into the output string during formatting or matched against the input string during parsing.
280
281 Due to the fact that dates may differ per locale, an optional property, defining the locale of the pattern, is provided. This would assist processing of source dates, according to the given locale{{footnote}}A list of commonly used locales can be found in the Java supported locales: https://www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html{{/footnote}}^^{{footnote}}A list of commonly used locales can be found in the Java supported locales: https://www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html{{/footnote}}^^. An indicative list of examples is presented in the following table:
282
283 (% style="width:604.294px" %)
284 |(% style="width:172px" %)English (en)|(% style="width:216px" %)Australia (AU)|(% style="width:213px" %)en-AU
285 |(% style="width:172px" %)English (en)|(% style="width:216px" %)Canada (CA)|(% style="width:213px" %)en-CA
286 |(% style="width:172px" %)English (en)|(% style="width:216px" %)United Kingdom (GB)|(% style="width:213px" %)en-GB
287 |(% style="width:172px" %)English (en)|(% style="width:216px" %)United States (US)|(% style="width:213px" %)en-US
288 |(% style="width:172px" %)Estonian (et)|(% style="width:216px" %)Estonia (EE)|(% style="width:213px" %)et-EE
289 |(% style="width:172px" %)Finnish (fi)|(% style="width:216px" %)Finland (FI)|(% style="width:213px" %)fi-FI
290 |(% style="width:172px" %)French (fr)|(% style="width:216px" %)Belgium (BE)|(% style="width:213px" %)fr-BE
291 |(% style="width:172px" %)French (fr)|(% style="width:216px" %)Canada (CA)|(% style="width:213px" %)fr-CA
292 |(% style="width:172px" %)French (fr)|(% style="width:216px" %)France (FR)|(% style="width:213px" %)fr-FR
293 |(% style="width:172px" %)French (fr)|(% style="width:216px" %)Luxembourg (LU)|(% style="width:213px" %)fr-LU
294 |(% style="width:172px" %)French (fr)|(% style="width:216px" %)Switzerland (CH)|(% style="width:213px" %)fr-CH
295 |(% style="width:172px" %)German (de)|(% style="width:216px" %)Austria (AT)|(% style="width:213px" %)de-AT
296 |(% style="width:172px" %)German (de)|(% style="width:216px" %)Germany (DE)|(% style="width:213px" %)de-DE
297 |(% style="width:172px" %)German (de)|(% style="width:216px" %)Luxembourg (LU)|(% style="width:213px" %)de-LU
298 |(% style="width:172px" %)German (de)|(% style="width:216px" %)Switzerland (CH)|(% style="width:213px" %)de-CH
299 |(% style="width:172px" %)Greek (el)|(% style="width:216px" %)Cyprus (CY)|(% style="width:213px" %)el-CY(*)
300 |(% style="width:172px" %)Greek (el)|(% style="width:216px" %)Greece (GR)|(% style="width:213px" %)el-GR
301 |(% style="width:172px" %)Hebrew (iw)|(% style="width:216px" %)Israel (IL)|(% style="width:213px" %)iw-IL
302 |(% style="width:172px" %)Hindi (hi)|(% style="width:216px" %)India (IN)|(% style="width:213px" %)hi-IN
303 |(% style="width:172px" %)Hungarian (hu)|(% style="width:216px" %)Hungary (HU)|(% style="width:213px" %)hu-HU
304 |(% style="width:172px" %)Icelandic (is)|(% style="width:216px" %)Iceland (IS)|(% style="width:213px" %)is-IS
305 |(% style="width:172px" %)Indonesian (in)|(% style="width:216px" %)Indonesia (ID)|(% style="width:213px" %)in-ID(*)
306 |(% style="width:172px" %)Irish (ga)|(% style="width:216px" %)Ireland (IE)|(% style="width:213px" %)ga-IE(*)
307 |(% style="width:172px" %)Italian (it)|(% style="width:216px" %)Italy (IT)|(% style="width:213px" %)it-IT
308
309 ~* - [[https:~~/~~/www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html#cldrlocale>>https://www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html#cldrlocale]]
310
311 Examples
312
313 22/06/1981 would be described as dd/MM/YYYY, with locale en-GB
314 2008-mars-12 would be described as YYYY-MMM-DD, with locale fr-FR
315 22 July 1981 would be described as dd MMMM YYYY, with locale en-US
316 22 Jul 1981 would be described as dd MMM YYYY
317 2010 D62 would be described as YYYYDnn (day 62 of the year 2010)
318
319 The following pattern letters are defined (all other characters from 'A' to 'Z' and from 'a' to 'z' are reserved):
320
321 (% style="width:850.294px" %)
322 |(% style="width:125px" %)**Letter**|(% style="width:385px" %)**Date or Time Component**|(% style="width:180px" %)**Presentation**|(% style="width:157px" %)**Examples**
323 |(% style="width:125px" %)G|(% style="width:385px" %)Era designator|(% style="width:180px" %)Text|(% style="width:157px" %)AD
324 |(% style="width:125px" %)yy|(% style="width:385px" %)Year short (upper case is Year of Week{{footnote}}yyyy represents the calendar year while YYYY represents the year of the week, which is only relevant for 53 week years{{/footnote}}^^{{footnote}}yyyy represents the calendar year while YYYY represents the year of the week, which is only relevant for 53 week years{{/footnote}}^^)|(% style="width:180px" %)Year|(% style="width:157px" %)96
325 |(% style="width:125px" %)yyyy|(% style="width:385px" %)Year Full (upper case is Year of Week)|(% style="width:180px" %)Year|(% style="width:157px" %)1996
326 |(% style="width:125px" %)MM|(% style="width:385px" %)Month number in year starting with 1|(% style="width:180px" %)Month|(% style="width:157px" %)07
327 |(% style="width:125px" %)MMM|(% style="width:385px" %)Month name short|(% style="width:180px" %)Month|(% style="width:157px" %)Jul
328 |(% style="width:125px" %)MMMM|(% style="width:385px" %)Month name full|(% style="width:180px" %)Month|(% style="width:157px" %)July
329 |(% style="width:125px" %)ww|(% style="width:385px" %)Week in year|(% style="width:180px" %)Number|(% style="width:157px" %)27
330 |(% style="width:125px" %)W|(% style="width:385px" %)Week in month|(% style="width:180px" %)Number|(% style="width:157px" %)2
331 |(% style="width:125px" %)DD|(% style="width:385px" %)Day in year|(% style="width:180px" %)Number|(% style="width:157px" %)189
332 |(% style="width:125px" %)dd|(% style="width:385px" %)Day in month|(% style="width:180px" %)Number|(% style="width:157px" %)10
333 |(% style="width:125px" %)F|(% style="width:385px" %)Day of week in month|(% style="width:180px" %)Number|(% style="width:157px" %)2
334 |(% style="width:125px" %)E|(% style="width:385px" %)Day name in week|(% style="width:180px" %)Text|(% style="width:157px" %)Tuesday; Tue
335 |(% style="width:125px" %)U|(% style="width:385px" %)Day number of week (1 = Monday, ..., 7 = Sunday)|(% style="width:180px" %)Number|(% style="width:157px" %)1
336 |(% style="width:125px" %)HH|(% style="width:385px" %)Hour in day (0-23)|(% style="width:180px" %)Number|(% style="width:157px" %)0
337 |(% style="width:125px" %)kk|(% style="width:385px" %)Hour in day (1-24)|(% style="width:180px" %)Number|(% style="width:157px" %)24
338 |(% style="width:125px" %)KK|(% style="width:385px" %)Hour in am/pm (0-11)|(% style="width:180px" %)Number|(% style="width:157px" %)0
339 |(% style="width:125px" %)hh|(% style="width:385px" %)Hour in am/pm (1-12)|(% style="width:180px" %)Number|(% style="width:157px" %)12
340 |(% style="width:125px" %)mm|(% style="width:385px" %)Minute in hour|(% style="width:180px" %)Number|(% style="width:157px" %)30
341 |(% style="width:125px" %)ss|(% style="width:385px" %)Second in minute|(% style="width:180px" %)Number|(% style="width:157px" %)55
342 |(% style="width:125px" %)S|(% style="width:385px" %)Millisecond|(% style="width:180px" %)Number|(% style="width:157px" %)978
343 |(% style="width:125px" %)n|(% style="width:385px" %)(((
344 Number of periods, used after a SDMX
345 Frequency Identifier such as M, Q, D (month, quarter, day)
346 )))|(% style="width:180px" %)Number|(% style="width:157px" %)12
347
348 The model is illustrated below:
349
350 (% contenteditable="false" tabindex="-1" %)[[image:1750074822764-573.png]]
351
352 **Figure 24 showing the component map mapping the SOURCE_DATE Dimension to the TIME_PERIOD dimension with the additional information on the component map to describe the time format?**
353
354 (% contenteditable="false" tabindex="-1" %)[[image:1750074865924-797.png]]
355
356 (% class="wikigeneratedid" id="HFigure25showinganinputdateformat2CwhoseoutputfrequencyisderivedfromtheoutputvalueoftheFREQDimension" %)
357 **Figure 25 showing an input date format, whose output frequency is derived from the output value of the FREQ Dimension**
358
359 === 13.7.2 Numerical based datetime ===
360
361 Where the source datetime input is purely numerical, the mapping rules are defined by the **Base** as a valid [[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] [[Time Period>>doc:sdmx:Glossary.Time period.WebHome]], and the **Period** which must take one of the following enumerated values:
362
363 * day
364 * second
365 * millisecond
366 * microsecond
367 * nanosecond
368
369 (% style="width:545.294px" %)
370 |(% style="width:268px" %)Numerical datetime systems|(% style="width:121px" %)Base|(% style="width:153px" %)Period
371 |(% style="width:268px" %)(((
372 Epoch Time (UNIX)
373 Milliseconds since 01 Jan 1970
374 )))|(% style="width:121px" %)1970|(% style="width:153px" %)millisecond
375 |(% style="width:268px" %)(((
376 Windows System Time
377 Milliseconds since 01 Jan 1601
378 )))|(% style="width:121px" %)1601|(% style="width:153px" %)millisecond
379
380 The example above illustrates numerical based datetime mapping rules for two commonly used time standards.
381
382 The model is illustrated below:
383
384 (% contenteditable="false" tabindex="-1" %)[[image:1750074994887-415.png]]
385
386 **Figure 26 showing the component map mapping the SOURCE_DATE Dimension to the TIME_PERIOD Dimension with the additional information on the component map to describe the numerical datetime system in use **
387
388 === 13.7.3 Mapping more complex time inputs ===
389
390 [[VTL>>doc:sdmx:Glossary.Validation and transformation language.WebHome]] should be used for more complex time inputs that cannot be interpreted using the pattern based on numerical methods.
391
392 == 13.8 Using TIME_PERIOD in mapping rules ==
393
394 The source TIME_PERIOD [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]] can be used in conjunction with other input [[Dimensions>>doc:sdmx:Glossary.Dimension.WebHome]] to create discrete mapping rules where the output is conditional on the [[time period>>doc:sdmx:Glossary.Time period.WebHome]] value.
395
396 The main use case is setting the value of Observation [[Attributes>>doc:sdmx:Glossary.Attribute.WebHome]] in the target [[dataset>>doc:sdmx:Glossary.Data set.WebHome]].
397
398 (% style="width:709.294px" %)
399 |(% style="width:103px" %)**Rule**|(% style="width:405px" %)**Source**|(% style="width:198px" %)**Target**
400 |(% style="width:103px" %)1|(% style="width:405px" %)(((
401 If
402 INDICATOR=XULADS; and TIME_PERIOD=2007.
403 )))|(% style="width:198px" %)(((
404 Set OBS_CONF=F
405 )))
406 |(% style="width:103px" %)2|(% style="width:405px" %)(((
407 If
408 INDICATOR=XULADS; and TIME_PERIOD=2008.
409 )))|(% style="width:198px" %)Set OBS_CONF=F
410 |(% style="width:103px" %)3|(% style="width:405px" %)(((
411 If
412 INDICATOR=XULADS; and TIME_PERIOD=2009.
413 )))|(% style="width:198px" %)(((
414 Set OBS_CONF=F
415 )))
416 |(% style="width:103px" %)4|(% style="width:405px" %)(((
417 If
418 INDICATOR=XULADS; and TIME_PERIOD=2010.
419 )))|(% style="width:198px" %)(((
420 Set OBS_CONF=**C**
421 )))
422
423 In the example above, OBS_CONF is an Observation [[Attribute>>doc:sdmx:Glossary.Attribute.WebHome]].
424
425 == 13.9 Time span mapping rules using validity periods ==
426
427 Creating discrete mapping rules for each TIME_PERIOD is impractical where rules need to cover a specific span of time regardless of frequency, and for high-frequency data.
428
429 Instead, an optional validity period can be set for each mapping.
430
431 By specifying validity periods, the example from Section 13.8 can be re-written using two rules as follows:
432
433 (% style="width:516.294px" %)
434 |(% style="width:74px" %)Rule|(% style="width:215px" %)Source|(% style="width:223px" %)Target
435 |(% style="width:74px" %)1|(% style="width:215px" %)(((
436 If
437 INDICATOR=XULADS.
438 Validity Period
439 start period=2007
440 end period=2009
441 )))|(% style="width:223px" %)Set OBS_CONF=F
442 |(% style="width:74px" %)2|(% style="width:215px" %)(((
443 If
444 INDICATOR=XULADS.
445 Validity Period
446 start period=2010
447 )))|(% style="width:223px" %)(((
448 Set
449 OBS_CONF=F
450 )))
451
452 In Rule 1, start period resolves to the start of the 2007 period (2007-01-01T00:00:00), and the end period resolves to the very end of 2009 (2009-12-31T23:59:59). The rule will hold true regardless of the input data frequency. Any observations reporting data for the Indicator XULADS that fall into that time range will have an OBS_CONF value of F.
453
454 In Rule 2, no end period is specified so remains in effect from the start of the period (2010-01-01T00:00:00) until the end of time. Any observations reporting data for the Indicator XULADS that fall into that time range will have an OBS_CONF value of C.
455
456 In Rule 2, no end period is specified so remains in effect from the start of the period (2010-01-01T00:00:00) until the end of time. Any observations reporting data for the Indicator XULADS that fall into that time range will have an OBS_CONF value of C.
457
458 == 13.10 Mapping examples ==
459
460 === 13.10.1 Many to one mapping (N3513 -1) ===
461
462 (% style="width:542.294px" %)
463 |(% style="width:274px" %)**Source**|(% style="width:265px" %)**Map To**
464 |(% style="width:274px" %)(((
465 (% style="color:#8e44ad" %)**FREQ**="A"
466 ADJUSTMENT="N"
467 **REF_AREA**="PL"
468 **COUNTERPART_AREA**="W0"
469 REF_SECTOR="S1"
470 COUNTERPART_SECTOR="S1"
471 ACCOUNTING_ENTRY="B"
472 STO="B5G"
473 )))|(% style="width:265px" %)(((
474 (% style="color:#8e44ad" %)FREQ="A"
475 REF_AREA="PL"
476 COUNTERPART_AREA="W0"
477 INDICATOR="IND_ABC"(%%)
478
479 )))
480
481 The bold [[Dimensions>>doc:sdmx:Glossary.Dimension.WebHome]] map from source to target verbatim. The mapping simply specifies:
482
483 > FREQ => FREQ
484 > REF_AREA=> REF_AREA
485 > COUNTERPART_AREA=> COUNTERPART _AREA
486
487 No [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Mapping is required. The source value simply copies across unmodified.
488
489 The remaining [[Dimensions>>doc:sdmx:Glossary.Dimension.WebHome]] all map to the Indicator [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]]. This is an example of many [[Dimensions>>doc:sdmx:Glossary.Dimension.WebHome]] mapping to one [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]]. In this case a [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Mapping is required, and the mapping first describes the input 'partial key' and how this maps to the target indicator:
490
491 > N:S1:S1:B:B5G => IND_ABC
492
493 Where the key sequence is based on the order specified in the mapping (i.e [[ADJUSTMENT>>doc:sdmx:Glossary.Adjustment.WebHome]], REF_SECTOR, etc will result in the first value N being taken from [[ADJUSTMENT>>doc:sdmx:Glossary.Adjustment.WebHome]] as this was the first item in the source [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]] list.
494
495 **Note**: The key order is NOT based on the [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]] order of the [[DSD>>doc:sdmx:Glossary.Data structure definition.WebHome]], as the mapping needs to be resilient to the [[DSD>>doc:sdmx:Glossary.Data structure definition.WebHome]] changing.
496
497 === 13.10.2 Mapping other data types to Code Id ===
498
499 In the case where the incoming data type is not a string and not a [[code>>doc:sdmx:Glossary.Code.WebHome]] identifier i.e. the source [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]] is of type Integer and the target is Codelist. This is supported by the RepresentationMap. The RepresentationMap source can reference a Codelist, Valuelist, or be free text, the free text can include regular expressions.
500
501 The following [[representation>>doc:sdmx:Glossary.Representation.WebHome]] mapping can be used to explicitly map each [[age>>doc:sdmx:Glossary.Age.WebHome]] to an output [[code>>doc:sdmx:Glossary.Code.WebHome]].
502
503 (% style="width:402.294px" %)
504 |(% style="width:197px" %)**Source Input Free Text**|(% style="width:204px" %)**Desired Output Code Id**
505 |(% style="width:197px" %)0|(% style="width:204px" %)A
506 |(% style="width:197px" %)1|(% style="width:204px" %)A
507 |(% style="width:197px" %)2|(% style="width:204px" %)A
508 |(% style="width:197px" %)3|(% style="width:204px" %)B
509 |(% style="width:197px" %)4|(% style="width:204px" %)B
510
511 If this mapping takes advantage of regular expressions it can be expressed in two rules:
512
513 (% style="width:336.294px" %)
514 |(% style="width:182px" %)**Regular Expression**|(% style="width:151px" %)**Desired Output**
515 |(% style="width:182px" %)[0-2]|(% style="width:151px" %)A
516 |(% style="width:182px" %)[3-4]|(% style="width:151px" %)B
517
518 === 13.10.3 Observation Attributes for Time Period ===
519
520 This use case is where a specific observation for a specific [[time period>>doc:sdmx:Glossary.Time period.WebHome]] has an [[attribute>>doc:sdmx:Glossary.Attribute.WebHome]] value.
521
522 (% style="width:621.294px" %)
523 |(% style="width:201px" %)Input INDICATOR|(% style="width:192px" %)Input TIME_PERIOD|(% style="width:225px" %)Output OBS_CONF
524 |(% style="width:201px" %)XULADS|(% style="width:192px" %)2008|(% style="width:225px" %)C
525 |(% style="width:201px" %)XULADS|(% style="width:192px" %)2009|(% style="width:225px" %)C
526 |(% style="width:201px" %)XULADS|(% style="width:192px" %)2010|(% style="width:225px" %)C
527
528 Or using a validity period on the [[Representation>>doc:sdmx:Glossary.Representation.WebHome]] Mapping:
529
530 (% style="width:629.294px" %)
531 |(% style="width:202px" %)Input INDICATOR|(% style="width:197px" %)Valid From/ Valid To|(% style="width:227px" %) Output OBS_CONF
532 |(% style="width:202px" %)XULADS|(% style="width:197px" %) 2008/2010|(% style="width:227px" %)С
533
534 === 13.10.4 Time mapping ===
535
536 This use case is to create a [[time period>>doc:sdmx:Glossary.Time period.WebHome]] from an input that does not respect [[SDMX>>doc:sdmx:Glossary.Statistical data and metadata exchange.WebHome]] Time Formats.
537
538 The [[Component>>doc:sdmx:Glossary.Component.WebHome]] Mapping from SYS_TIME to TIME_PERIOD specifies itself as a time mapping with the following details:
539
540 (% style="width:652.294px" %)
541 |(% style="width:139px" %)Source Value|(% style="width:165px" %)Source Mapping|(% style="width:182px" %)Target Frequency|(% style="width:163px" %)Output
542 |(% style="width:139px" %)18/07/1981|(% style="width:165px" %)dd/MM/yyyy|(% style="width:182px" %)A|(% style="width:163px" %)1981
543
544 When the target frequency is based on another target [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]] value, in this example the value of the FREQ [[Dimension>>doc:sdmx:Glossary.Dimension.WebHome]] in the target [[DSD>>doc:sdmx:Glossary.Data structure definition.WebHome]].
545
546 (% style="width:658.294px" %)
547 |(% style="width:143px" %)Source Value|(% style="width:163px" %) Source Mapping|(% style="width:176px" %)Target Dimension|(% style="width:173px" %)Frequency Output
548 |(% style="width:143px" %)18/07/1981|(% style="width:163px" %)dd/MM/yyyy|(% style="width:176px" %)FREQ|(% style="width:173px" %)1981-07-18 (when FREQ=D)
549
550 When the source is a numerical format.
551
552 (% style="width:658.294px" %)
553 |(% style="width:143px" %)Source Value|(% style="width:163px" %) Start Period|(% style="width:176px" %)Interval|(% style="width:176px" %)Target FREQ|(% style="width:173px" %) Output
554 |(% style="width:143px" %)1589808220|(% style="width:163px" %)1970|(% style="width:176px" %) millisecond|(% style="width:176px" %)M|(% style="width:173px" %)2020-05
555
556 When the source frequency is lower than the target frequency additional information 3568 can be provided for resolve to start of period, end of period, or mid period, as shown 3569 in the following example:
557
558 (% style="width:666.294px" %)
559 |(% style="width:131px" %) Source Value|(% style="width:143px" %)Source Mapping|(% style="width:149px" %)Target Dimension|(% style="width:114px" %)Frequency|(% style="width:126px" %)Output
560 |(% style="width:131px" %)1981|(% style="width:143px" %)yyyy|(% style="width:149px" %)D – End of Period|(% style="width:114px" %) |(% style="width:126px" %)1981-12-31
561
562 When the start of year is April 1^^st^^ the Structure Map has YearStart=04-01:
563
564 (% style="width:666.294px" %)
565 |(% style="width:131px" %) Source Value|(% style="width:143px" %)Source Mapping|(% style="width:149px" %)Target Dimension|(% style="width:114px" %)Frequency|(% style="width:126px" %)Output
566 |(% style="width:131px" %)1981|(% style="width:143px" %)yyyy|(% style="width:149px" %)D – End of Period|(% style="width:114px" %) |(% style="width:126px" %)1982-03-31
567
568 ----
569
570 (% contenteditable="false" tabindex="-1" %)
571 (((
572 {{putFootnotes/}}
573 )))