Map codes between classification versions
Find a concordance between two classification versions and build a migration function that handles mergers, splits, and renames — with proportional allocation for one-to-many mappings.
When Statistics Canada releases a new classification version, they publish a concordance — a directed mapping that documents exactly how each code in the old version relates to each code in the new version. This guide walks through migrating historical data from NAICS 2017 to NAICS 2022.
What concordances contain
A concordance has a source classification and a target classification. Its codeMaps array contains one entry per source code, recording the relationship type and the target code(s):
maptype | Meaning |
|---|---|
No Change | Same code number, same definition — no action needed |
Code Change | Same industry, but the code number changed |
Property Change | Minor scope or definition change, code may be the same or different |
Merger | Multiple old codes collapsed into one new code |
Breakdown | One old code expanded into multiple new codes |
Split-off | Part of an old code moved to a new code; original code still exists |
Take-over | An industry moved from one code to another that also has its own content |
For Breakdown and Merger mappings, distributionFactor tells you what proportion of the old code's value should be allocated to each new code. A 50/50 split between two new codes would give distributionFactor: 0.5 on each mapping.
Step 1 — Find the concordance
Concordances are directional. A NAICS 2017 → 2022 concordance is a different object from a NAICS 2022 → 2017 concordance. Make sure the source and target match the direction you need before extracting the ID.
Step 2 — Retrieve the full code map
Step 3 — Understand many-to-many mappings
A single source code can map to multiple target codes when a Breakdown or Split-off occurs. Group the codeMaps by sourceCode to see the full picture:
Example output for a Breakdown:
Step 4 — Build a lookup map for fast migration
Pre-compute a Map<sourceCode, CodeMap[]> so you can migrate individual codes in O(1):
Complete example — NAICS 2017 → 2022 migration function
distributionFactor is null for No Change, Code Change, and Property Change mappings. It is only meaningful — and only populated — for Merger, Breakdown, Split-off, and Take-over mappings where value must be apportioned across multiple targets. Always fall back to 1.0 when the field is null.
Handling reverse lookups
If you need to go backward — given a 2022 code, find what 2017 code(s) it came from — build a reverse map from targetCode:
Note that the reverseDistributionFactor field on each CodeMap provides the inverse allocation weight for this direction.