*! version 1.0.0 December 12, 2020

Title

recocl - Recodes municipality's codes for Chile (CL)

Syntax

recocl
codevar,
year(year)
[option]

Main
year(year) Specifies the year of municipal code change (2007 or 2017). This is required.

generate(name) Specifies the name of the new variable. Default is overwrite the code-variable.

Description

recocl

Chile has changed his municipal code a couple of times. Currently, not all databases have the most current
municipality code, therefore it is necessary to carry out a recoding of the municipality code for some municipalities
in region I (Arica y Parinacota), VIII (Bio-Bio) and X (Los Ríos). This is exactly what recocl does, recode 12
municipalities that become region 14, recode the 4 municipalities that become region 15 in 2007 and recode
the 21 municipalities that become region 16 in 2017. The list of municipalities are:

+
+
| Los Ríos 2007 |
| Old Code New Code |
| X XIV |
+
+
| 10501 -> 14104 |
| 10502 -> 14102 |
| 10506 -> 14103 |
| 10507 -> 14104 |
| 10508 -> 14105 |
| 10509 -> 14106 |
| 10510 -> 14107 |
| 10511 -> 14108 |
| 10504 -> 14201 |
| 10503 -> 14202 |
| 10505 -> 14203 |
| 10512 -> 14204 |
+
+

+
+
|Arica Parinacota 2007|
| Old Code New Code |
| I XV |
+
+
| 1201 -> 15101 |
| 1202 -> 15102 |
| 1301 -> 15201 |
| 1302 -> 15202 |
+
+

+
+
| Ñuble 2017 |
| Old Code New Code |
| XIII XVI |
+
+
| 8401 -> 16101 |
| 8402 -> 16102 |
| 8406 -> 16103 |
| 8407 -> 16104 |
| 8410 -> 16105 |
| 8411 -> 16106 |
| 8413 -> 16107 |
| 8418 -> 16108 |
| 8421 -> 16109 |
| 8414 -> 16201 |
| 8403 -> 16202 |
| 8404 -> 16203 |
| 8408 -> 16204 |
| 8412 -> 16205 |
| 8415 -> 16206 |
| 8420 -> 16207 |
| 8416 -> 16301 |
| 8405 -> 16302 |
| 8409 -> 16303 |
| 8417 -> 16304 |
| 8419 -> 16305 |
+
+

Examples

If we have a municipal database from 2015 and we want to do some merge with a database from 2018
we need recode the municipal variable. We must know the year of change that we need to apply, in this case 2017:

.recocl comuna, y(2017)

If we want to create a new variable, we must add gen() option.

.recocl comuna, y(2017) gen(newcode)

Acknowledgements

I am grateful to Ignacio García and Camilo Acuña for feedback.

Author

Daniel Pailañir
Email daniel.pailanir@gmail.com