/* Reads demographic data */

libname lib24 "W:\Uudet_datat\U0599_9_toim\";
libname lib100 "W:\Tutkimusprojektit\Kirjanpito\Dokumentaatio\JAR\Datat\";
run;

* Data from 1987 onwards;

data demografiset;
 set lib24.demografiset_9_s;
 ID = shnro;					* Unique identifier for each person;
 GENDER = sukup; 				* 1 = male, 2 = female;
 AGE = ika; 					* Expressed as full years on the last day of the year;
 CITIZENSHIP = kansa1; 			* 1 = Finland, 2 = Other ;
 YEAR = vuosi;
 MARITAL_STATUS = sivs; 		* 1 = not married, 2 = married/registered partnership, 4 = divorced, 5 = widow;
 OCCUPATION_POSITION = amas1; 		* 1 = employee, 2 = entrepreneur;
 OCCUPATION_CODE = ammattikoodi;	* Definitions given in FLEED;
 SOCIOECONOMIC_POSITION = sose; 	* Definitions given in FLEED;
 FAMILY_POSITION = peas; 		* Family position, definitions given in FLEED;
 NATIVE_LANGUAGE = kieli; 		* fi = Finnish, sv = Swedish, 9 = other;
 EMPLOYMENT_MONTHS = tyokk; 		* Calculated since year 2005;
 FAMILYTYPE = pety; 			* 1 = married, no children, 2 = married, children, 3 = mother and children, 4 = father and children, 5 = unmarried couple and common children, 6 = unmarried couple and non-common children only, 7 = unmarried and no children, missing = no family;
 FAMILYSIZE = pekoko; 			* The number of persons in the family;
 NUM_CHILDREN_UNDER_7 = a7lkm; 		* Number of children under age of 7 in family;
 NUM_CHILDREN_UNDER_18 = a18lkm; 	* Number of children under age of 18 in family;
 HOUSEHOLD_SIZE = akoko; 		* Number of persons living under same house;
 RESIDENTIALFORM = hape; 		* House owner, tenant, other (1, 2 = owner, 3, 4, 5 = tenant, 6, 7 = other, 9 = unknown;
 MUNICIPALITY = kunta;			* Kunta not specified in FLEED, see the code;
 BIRTHYEAR = YEAR - AGE;

 drop sukup ika sukup ika kansa1 vuosi sivs amas1 ammattikoodi sose peas kieli tyokk ututku suorv pety pekoko a7lkm a18lkm akoko hape lkm kunta shnro;
run;

proc sort nodupkey data = demografiset;	
 by ID YEAR;
run;

data demografiset_2;
 set demografiset;

 MALE = 0;				
 if GENDER = '1' then MALE = 1;

 FEMALE = 0;				
 if GENDER = '2' then FEMALE = 1;

 BIRTHYEAR = YEAR - AGE;		

 if GENDER = ' ' then delete;		
 if AGE = ' ' then delete;	

 Divorce = 0;

 if id = lag(id) and MARITAL_STATUS = 4 and lag(MARITAL_STATUS) = 2 then Divorce = 1;

 Divorce_prev_5_years = 0;

 if ((id = lag5(id) and lag5(Divorce = 1)) or (id = lag4(id) and lag4(Divorce = 1)) or (id = lag3(id) and lag3(Divorce = 1)) or (id = lag2(id) and lag2(Divorce = 1)) or (id = lag(id) and lag(Divorce = 1))) then 
Divorce_prev_5_years = 1;

Married = 0;

if id = lag(id) and MARITAL_STATUS = 2 and lag(MARITAL_STATUS) ^= 2 then Married = 1;

if (MARITAL_STATUS = 2 and YEAR = 1987) then Married = 1;

Avoliitto = 0;

if familytype = 5 or familytype = 6 or familytype = 7 then Avoliitto = 1;

* Regions;

if MUNICIPALITY = '049' or MUNICIPALITY = '078' or MUNICIPALITY = '091' or MUNICIPALITY = '106' or MUNICIPALITY = '186' or MUNICIPALITY = '235' or MUNICIPALITY = '245' or
MUNICIPALITY = '257' or MUNICIPALITY = '444' or MUNICIPALITY = '638' or MUNICIPALITY = '858' or MUNICIPALITY = '092' or MUNICIPALITY = '224' or MUNICIPALITY = '434' or
MUNICIPALITY = '505' or MUNICIPALITY = '543' or MUNICIPALITY = '710' or MUNICIPALITY = '753' or MUNICIPALITY = '927' or MUNICIPALITY = '018' or MUNICIPALITY = '149' or
MUNICIPALITY = '407' or MUNICIPALITY = '504' or MUNICIPALITY = '611' or MUNICIPALITY = '616' or MUNICIPALITY = '755' or MUNICIPALITY = '428' or MUNICIPALITY = '540' or
MUNICIPALITY = '220' or MUNICIPALITY = '223' or MUNICIPALITY = '424' or MUNICIPALITY = '427' or MUNICIPALITY = '585' or MUNICIPALITY = '606' or MUNICIPALITY = '612' or
MUNICIPALITY = '613' or MUNICIPALITY = '701' or MUNICIPALITY = '737' or MUNICIPALITY = '835' or MUNICIPALITY = '842' then MAAKUNTA = 1;

if MUNICIPALITY = '202' or MUNICIPALITY = '680' or MUNICIPALITY = '734' or MUNICIPALITY = '853' or MUNICIPALITY = '400' or MUNICIPALITY = '423' or MUNICIPALITY = '430' or
MUNICIPALITY = '481' or MUNICIPALITY = '503' or MUNICIPALITY = '529' or MUNICIPALITY = '577' or MUNICIPALITY = '445' or MUNICIPALITY = '895' or MUNICIPALITY = '019' or
MUNICIPALITY = '322' or MUNICIPALITY = '284' or MUNICIPALITY = '304' or MUNICIPALITY = '480' or MUNICIPALITY = '538' or MUNICIPALITY = '561' or MUNICIPALITY = '631' or
MUNICIPALITY = '636' or MUNICIPALITY = '704' or MUNICIPALITY = '738' or MUNICIPALITY = '761' or MUNICIPALITY = '833' or MUNICIPALITY = '918' or MUNICIPALITY = '040' or
MUNICIPALITY = '073' or MUNICIPALITY = '573' or MUNICIPALITY = '006' or MUNICIPALITY = '017' or MUNICIPALITY = '101' or MUNICIPALITY = '150' or MUNICIPALITY = '209' or
MUNICIPALITY = '219' or MUNICIPALITY = '243' or MUNICIPALITY = '252' or MUNICIPALITY = '259' or MUNICIPALITY = '279' or MUNICIPALITY = '308' or MUNICIPALITY = '419' or
MUNICIPALITY = '431' or MUNICIPALITY = '482' or MUNICIPALITY = '485' or MUNICIPALITY = '490' or MUNICIPALITY = '501' or MUNICIPALITY = '533' or MUNICIPALITY = '586' or
MUNICIPALITY = '587' or MUNICIPALITY = '602' or MUNICIPALITY = '705' or MUNICIPALITY = '776' or MUNICIPALITY = '784' or MUNICIPALITY = '838' or MUNICIPALITY = '906' or
MUNICIPALITY = '920' or MUNICIPALITY = '923' or MUNICIPALITY = '979' then MAAKUNTA = 2;

if MUNICIPALITY = '079' or MUNICIPALITY = '609' or MUNICIPALITY = '684' or MUNICIPALITY = '050' or MUNICIPALITY = '102' or MUNICIPALITY = '214' or MUNICIPALITY = '531' or
MUNICIPALITY = '886' or MUNICIPALITY = '051' or MUNICIPALITY = '099' or MUNICIPALITY = '181' or MUNICIPALITY = '230' or MUNICIPALITY = '271' or MUNICIPALITY = '319' or
MUNICIPALITY = '442' or MUNICIPALITY = '484' or MUNICIPALITY = '608' or MUNICIPALITY = '747' or MUNICIPALITY = '783' or MUNICIPALITY = '537' or MUNICIPALITY = '254' or
MUNICIPALITY = '262' or MUNICIPALITY = '266' or MUNICIPALITY = '293' or MUNICIPALITY = '406' or MUNICIPALITY = '413' or MUNICIPALITY = '685' or MUNICIPALITY = '913'
then MAAKUNTA = 4;

if MUNICIPALITY = '061' or MUNICIPALITY = '109' or MUNICIPALITY = '694' or MUNICIPALITY = '082' or MUNICIPALITY = '165' or MUNICIPALITY = '086' or MUNICIPALITY = '103' or
MUNICIPALITY = '169' or MUNICIPALITY = '433' or MUNICIPALITY = '834' or MUNICIPALITY = '981' or MUNICIPALITY = '083' or MUNICIPALITY = '210' or MUNICIPALITY = '401' or
MUNICIPALITY = '692' or MUNICIPALITY = '855' then MAAKUNTA = 5;

if MUNICIPALITY = '211' or MUNICIPALITY = '418' or MUNICIPALITY = '536' or MUNICIPALITY = '604' or MUNICIPALITY = '837' or MUNICIPALITY = '908' or MUNICIPALITY = '980' or
MUNICIPALITY = '020' or MUNICIPALITY = '108' or MUNICIPALITY = '508' or MUNICIPALITY = '562' or MUNICIPALITY = '581' or MUNICIPALITY = '790' or MUNICIPALITY = '143' or
MUNICIPALITY = '177' or MUNICIPALITY = '250' or MUNICIPALITY = '619' or MUNICIPALITY = '635' or MUNICIPALITY = '702' or MUNICIPALITY = '887' or MUNICIPALITY = '922' or
MUNICIPALITY = '936' or MUNICIPALITY = '864' or MUNICIPALITY = '310' or MUNICIPALITY = '289' or MUNICIPALITY = '299' or MUNICIPALITY = '303' or MUNICIPALITY = '439' or 
MUNICIPALITY = '443' or MUNICIPALITY = '493' or MUNICIPALITY = '506' or MUNICIPALITY = '730' or MUNICIPALITY = '772' or MUNICIPALITY = '864' or MUNICIPALITY = '912' or
MUNICIPALITY = '928' or MUNICIPALITY = '932' or MUNICIPALITY = '933' or MUNICIPALITY = '988' then MAAKUNTA = 6;

if MUNICIPALITY = '111' or MUNICIPALITY = '098' or MUNICIPALITY = '398' or MUNICIPALITY = '016' or MUNICIPALITY = '532' or MUNICIPALITY = '560' or MUNICIPALITY = '081' or
MUNICIPALITY = '283' or MUNICIPALITY = '316' or MUNICIPALITY = '576' or MUNICIPALITY = '781' or MUNICIPALITY = '015' or MUNICIPALITY = '088' or MUNICIPALITY = '089' then MAAKUNTA = 7;

if MUNICIPALITY = '075' or MUNICIPALITY = '285' or MUNICIPALITY = '286' or MUNICIPALITY = '142' or MUNICIPALITY = '489' or MUNICIPALITY = '624' or MUNICIPALITY = '935' or
MUNICIPALITY = '306' or MUNICIPALITY = '044' or MUNICIPALITY = '163' or MUNICIPALITY = '754' or MUNICIPALITY = '909' or MUNICIPALITY = '917' then MAAKUNTA = 8;

if MUNICIPALITY = '153' or MUNICIPALITY = '405' or MUNICIPALITY = '416' or MUNICIPALITY = '441' or MUNICIPALITY = '580' or MUNICIPALITY = '689' or MUNICIPALITY = '700' or
MUNICIPALITY = '739' or MUNICIPALITY = '831' or MUNICIPALITY = '173' or MUNICIPALITY = '539' or MUNICIPALITY = '728' or MUNICIPALITY = '775' or MUNICIPALITY = '891' or 
MUNICIPALITY = '978' then MAAKUNTA = 9;

if MUNICIPALITY = '491' or MUNICIPALITY = '740' or MUNICIPALITY = '507' or MUNICIPALITY = '593' or MUNICIPALITY = '046' or MUNICIPALITY = '090' or MUNICIPALITY = '097' or
MUNICIPALITY = '171' or MUNICIPALITY = '178' or MUNICIPALITY = '213' or MUNICIPALITY = '588' or MUNICIPALITY = '623' or MUNICIPALITY = '681' or MUNICIPALITY = '768' or 
MUNICIPALITY = '014' or MUNICIPALITY = '085' or MUNICIPALITY = '184' or MUNICIPALITY = '246' or MUNICIPALITY = '492' or MUNICIPALITY = '594' or MUNICIPALITY = '618' or
MUNICIPALITY = '640' or MUNICIPALITY = '696' or MUNICIPALITY = '741' or MUNICIPALITY = '937' then MAAKUNTA = 10;

if MUNICIPALITY = '140' or MUNICIPALITY = '297' or MUNICIPALITY = '915' or MUNICIPALITY = '749' or MUNICIPALITY = '778' or MUNICIPALITY = '174' or MUNICIPALITY = '204' or
MUNICIPALITY = '239' or MUNICIPALITY = '263' or MUNICIPALITY = '402' or MUNICIPALITY = '420' or MUNICIPALITY = '595' or MUNICIPALITY = '686' or MUNICIPALITY = '687' or
MUNICIPALITY = '762' or MUNICIPALITY = '844' or MUNICIPALITY = '857' or MUNICIPALITY = '921' or MUNICIPALITY = '925' or MUNICIPALITY = '227' or MUNICIPALITY = '212' or 
MUNICIPALITY = '476' or MUNICIPALITY = '534' or MUNICIPALITY = '916' or MUNICIPALITY = '919' then MAAKUNTA = 11;

if MUNICIPALITY = '167' or MUNICIPALITY = '276' or MUNICIPALITY = '422' or MUNICIPALITY = '541' or MUNICIPALITY = '309' or MUNICIPALITY = '146' or MUNICIPALITY = '176' or
MUNICIPALITY = '260' or MUNICIPALITY = '426' or MUNICIPALITY = '607' or MUNICIPALITY = '707' or MUNICIPALITY = '848' or MUNICIPALITY = '911' or MUNICIPALITY = '045' or 
MUNICIPALITY = '248' or MUNICIPALITY = '251' or MUNICIPALITY = '632' or MUNICIPALITY = '856' or MUNICIPALITY = '943' then MAAKUNTA = 12;

if MUNICIPALITY = '179' or MUNICIPALITY = '182' or MUNICIPALITY = '249' or MUNICIPALITY = '410' or MUNICIPALITY = '500' or MUNICIPALITY = '992' or MUNICIPALITY = '077' or
MUNICIPALITY = '172' or MUNICIPALITY = '216' or MUNICIPALITY = '226' or MUNICIPALITY = '256' or MUNICIPALITY = '265' or MUNICIPALITY = '275' or MUNICIPALITY = '291' or
MUNICIPALITY = '312' or MUNICIPALITY = '435' or MUNICIPALITY = '495' or MUNICIPALITY = '592' or MUNICIPALITY = '601' or MUNICIPALITY = '729' or MUNICIPALITY = '850' or
MUNICIPALITY = '892' or MUNICIPALITY = '931' or MUNICIPALITY = '787' or MUNICIPALITY = '180' or MUNICIPALITY = '183' or MUNICIPALITY = '274' or MUNICIPALITY = '277' or
MUNICIPALITY = '415' or MUNICIPALITY = '633' or MUNICIPALITY = '770' or MUNICIPALITY = '774' or MUNICIPALITY = '787' then MAAKUNTA = 13;

if MUNICIPALITY = '743' or MUNICIPALITY = '145' or MUNICIPALITY = '232' or MUNICIPALITY = '233' or MUNICIPALITY = '301' or MUNICIPALITY = '408' or MUNICIPALITY = '005' or
MUNICIPALITY = '010' or MUNICIPALITY = '052' or MUNICIPALITY = '151' or MUNICIPALITY = '164' or MUNICIPALITY = '218' or MUNICIPALITY = '300' or MUNICIPALITY = '403' or
MUNICIPALITY = '759' or MUNICIPALITY = '846' or MUNICIPALITY = '934' or MUNICIPALITY = '989' or MUNICIPALITY = '589' or MUNICIPALITY = '544' or MUNICIPALITY = '004' or 
MUNICIPALITY = '175' or MUNICIPALITY = '281' or MUNICIPALITY = '414' or MUNICIPALITY = '863' or MUNICIPALITY = '971' or MUNICIPALITY = '975' then MAAKUNTA = 14;

if MUNICIPALITY = '231' or MUNICIPALITY = '598' or MUNICIPALITY = '905' or MUNICIPALITY = '399' or MUNICIPALITY = '499' or MUNICIPALITY = '152' or MUNICIPALITY = '280' or
MUNICIPALITY = '287' or MUNICIPALITY = '288' or MUNICIPALITY = '440' or MUNICIPALITY = '475' or MUNICIPALITY = '545' or MUNICIPALITY = '599' or MUNICIPALITY = '893' or
MUNICIPALITY = '946' or MUNICIPALITY = '479' or MUNICIPALITY = '559' or MUNICIPALITY = '942' or MUNICIPALITY = '944' or MUNICIPALITY = '945' then MAAKUNTA = 15;

if MUNICIPALITY = '272' or MUNICIPALITY = '074' or MUNICIPALITY = '217' or MUNICIPALITY = '236' or MUNICIPALITY = '421' or MUNICIPALITY = '584' or MUNICIPALITY = '849' or
MUNICIPALITY = '924' or MUNICIPALITY = '315' or MUNICIPALITY = '429' or MUNICIPALITY = '885' then MAAKUNTA = 16;

if MUNICIPALITY = '244' or MUNICIPALITY = '564' or MUNICIPALITY = '678' or MUNICIPALITY = '069' or MUNICIPALITY = '139' or MUNICIPALITY = '208' or MUNICIPALITY = '305' or
MUNICIPALITY = '425' or MUNICIPALITY = '494' or MUNICIPALITY = '535' or MUNICIPALITY = '563' or MUNICIPALITY = '977' or MUNICIPALITY = '009' or MUNICIPALITY = '071' or
MUNICIPALITY = '072' or MUNICIPALITY = '317' or MUNICIPALITY = '436' or MUNICIPALITY = '483' or MUNICIPALITY = '615' or MUNICIPALITY = '625' or MUNICIPALITY = '626' or
MUNICIPALITY = '630' or MUNICIPALITY = '691' or MUNICIPALITY = '746' or MUNICIPALITY = '748' or MUNICIPALITY = '791' or MUNICIPALITY = '832' or MUNICIPALITY = '859' or
MUNICIPALITY = '889' or MUNICIPALITY = '926' or MUNICIPALITY = '255' or MUNICIPALITY = '084' or MUNICIPALITY = '095' or MUNICIPALITY = '247' or MUNICIPALITY = '292' or
MUNICIPALITY = '567' or MUNICIPALITY = '582' or MUNICIPALITY = '603' or MUNICIPALITY = '617' or MUNICIPALITY = '682' or MUNICIPALITY = '708' or MUNICIPALITY = '841' or
MUNICIPALITY = '972' or MUNICIPALITY = '973' then MAAKUNTA = 17;

if MUNICIPALITY = '205' or MUNICIPALITY = '290' or MUNICIPALITY = '777' or MUNICIPALITY = '105' or MUNICIPALITY = '578' or MUNICIPALITY = '620' or MUNICIPALITY = '697' or
MUNICIPALITY = '765' or MUNICIPALITY = '785' or MUNICIPALITY = '940' then MAAKUNTA = 18;

if MUNICIPALITY = '240' or MUNICIPALITY = '698' or MUNICIPALITY = '851' or MUNICIPALITY = '320' or MUNICIPALITY = '241' or MUNICIPALITY = '047' or MUNICIPALITY = '148' or
MUNICIPALITY = '261' or MUNICIPALITY = '273' or MUNICIPALITY = '498' or MUNICIPALITY = '583' or MUNICIPALITY = '854' or MUNICIPALITY = '614' or MUNICIPALITY = '683' or
MUNICIPALITY = '732' or MUNICIPALITY = '742' or MUNICIPALITY = '751' or MUNICIPALITY = '758' or MUNICIPALITY = '845' or MUNICIPALITY = '890' or MUNICIPALITY = '976' or
MUNICIPALITY = '699' then MAAKUNTA = 19;

if MUNICIPALITY = '478' or MUNICIPALITY = '035' or MUNICIPALITY = '043' or MUNICIPALITY = '060' or MUNICIPALITY = '062' or MUNICIPALITY = '065' or MUNICIPALITY = '076' or
MUNICIPALITY = '170' or MUNICIPALITY = '295' or MUNICIPALITY = '318' or MUNICIPALITY = '417' or MUNICIPALITY = '438' or MUNICIPALITY = '736' or MUNICIPALITY = '766' or
MUNICIPALITY = '771' or MUNICIPALITY = '941' then MAAKUNTA = 21;

* Adjusts due to changes in municipalities during the sample period;

MUNICIPALITY2 = MUNICIPALITY;

if MUNICIPALITY = '539' then MUNICIPALITY2 = '405'; if MUNICIPALITY = '787' then MUNICIPALITY2 = '179'; if MUNICIPALITY = '685' then MUNICIPALITY2 = '684'; if MUNICIPALITY = '842' then MUNICIPALITY2 = '710';
if MUNICIPALITY = '209' then MUNICIPALITY2 = '895'; if MUNICIPALITY = '274' then MUNICIPALITY2 = '992'; if MUNICIPALITY = '089' then MUNICIPALITY2 = '111'; if MUNICIPALITY = '088' then MUNICIPALITY2 = '111';
if MUNICIPALITY = '428' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '427' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '613' then MUNICIPALITY2 = '638'; if MUNICIPALITY = '612' then MUNICIPALITY2 = '638';
if MUNICIPALITY = '299' then MUNICIPALITY2 = '182'; if MUNICIPALITY = '014' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '492' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '841' then MUNICIPALITY2 = '859';
if MUNICIPALITY = '917' then MUNICIPALITY2 = '075'; if MUNICIPALITY = '582' then MUNICIPALITY2 = '678'; if MUNICIPALITY = '184' then MUNICIPALITY2 = '593'; if MUNICIPALITY = '594' then MUNICIPALITY2 = '593';
if MUNICIPALITY = '937' then MUNICIPALITY2 = '593'; if MUNICIPALITY = '640' then MUNICIPALITY2 = '593'; if MUNICIPALITY = '251' then MUNICIPALITY2 = '167'; if MUNICIPALITY = '856' then MUNICIPALITY2 = '167';
if MUNICIPALITY = '730' then MUNICIPALITY2 = '211'; if MUNICIPALITY = '919' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '431' then MUNICIPALITY2 = '430'; if MUNICIPALITY = '728' then MUNICIPALITY2 = '580';
if MUNICIPALITY = '891' then MUNICIPALITY2 = '580'; if MUNICIPALITY = '219' then MUNICIPALITY2 = '636'; if MUNICIPALITY = '589' then MUNICIPALITY2 = '743'; if MUNICIPALITY = '943' then MUNICIPALITY2 = '848';
if MUNICIPALITY = '293' then MUNICIPALITY2 = '886'; if MUNICIPALITY = '212' then MUNICIPALITY2 = '915'; if MUNICIPALITY = '699' then MUNICIPALITY2 = '698'; if MUNICIPALITY = '864' then MUNICIPALITY2 = '020';
if MUNICIPALITY = '928' then MUNICIPALITY2 = '020'; if MUNICIPALITY = '292' then MUNICIPALITY2 = '139'; if MUNICIPALITY = '443' then MUNICIPALITY2 = '182'; if MUNICIPALITY = '940' then MUNICIPALITY2 = '205';
if MUNICIPALITY = '085' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '490' then MUNICIPALITY2 = '503'; if MUNICIPALITY = '439' then MUNICIPALITY2 = '635'; if MUNICIPALITY = '266' then MUNICIPALITY2 = '684';
if MUNICIPALITY = '708' then MUNICIPALITY2 = '748'; if MUNICIPALITY = '772' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '479' then MUNICIPALITY2 = '946'; if MUNICIPALITY = '944' then MUNICIPALITY2 = '946';
if MUNICIPALITY = '932' then MUNICIPALITY2 = '980'; if MUNICIPALITY = '770' then MUNICIPALITY2 = '992'; if MUNICIPALITY = '774' then MUNICIPALITY2 = '992'; if MUNICIPALITY = '415' then MUNICIPALITY2 = '172';
if MUNICIPALITY = '414' then MUNICIPALITY2 = '005'; if MUNICIPALITY = '262' then MUNICIPALITY2 = '050'; if MUNICIPALITY = '913' then MUNICIPALITY2 = '102'; if MUNICIPALITY = '083' then MUNICIPALITY2 = '109';
if MUNICIPALITY = '210' then MUNICIPALITY2 = '109'; if MUNICIPALITY = '401' then MUNICIPALITY2 = '109'; if MUNICIPALITY = '692' then MUNICIPALITY2 = '109'; if MUNICIPALITY = '855' then MUNICIPALITY2 = '109';
if MUNICIPALITY = '045' then MUNICIPALITY2 = '167'; if MUNICIPALITY = '632' then MUNICIPALITY2 = '167'; if MUNICIPALITY = '180' then MUNICIPALITY2 = '179'; if MUNICIPALITY = '277' then MUNICIPALITY2 = '179';
if MUNICIPALITY = '183' then MUNICIPALITY2 = '182'; if MUNICIPALITY = '602' then MUNICIPALITY2 = '202'; if MUNICIPALITY = '004' then MUNICIPALITY2 = '233'; if MUNICIPALITY = '281' then MUNICIPALITY2 = '233';
if MUNICIPALITY = '971' then MUNICIPALITY2 = '233'; if MUNICIPALITY = '040' then MUNICIPALITY2 = '322'; if MUNICIPALITY = '243' then MUNICIPALITY2 = '322'; if MUNICIPALITY = '923' then MUNICIPALITY2 = '322';
if MUNICIPALITY = '315' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '429' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '885' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '754' then MUNICIPALITY2 = '286';
if MUNICIPALITY = '044' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '163' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '306' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '909' then MUNICIPALITY2 = '286';
if MUNICIPALITY = '175' then MUNICIPALITY2 = '301'; if MUNICIPALITY = '173' then MUNICIPALITY2 = '405'; if MUNICIPALITY = '737' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '006' then MUNICIPALITY2 = '430';
if MUNICIPALITY = '482' then MUNICIPALITY2 = '430'; if MUNICIPALITY = '101' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '150' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '279' then MUNICIPALITY2 = '445';
if MUNICIPALITY = '533' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '573' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '017' then MUNICIPALITY2 = '481'; if MUNICIPALITY = '419' then MUNICIPALITY2 = '481';
if MUNICIPALITY = '506' then MUNICIPALITY2 = '508'; if MUNICIPALITY = '933' then MUNICIPALITY2 = '508'; if MUNICIPALITY = '485' then MUNICIPALITY2 = '529'; if MUNICIPALITY = '705' then MUNICIPALITY2 = '529';
if MUNICIPALITY = '920' then MUNICIPALITY2 = '529'; if MUNICIPALITY = '973' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '979' then MUNICIPALITY2 = '636'; if MUNICIPALITY = '220' then MUNICIPALITY2 = '710';
if MUNICIPALITY = '606' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '835' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '406' then MUNICIPALITY2 = '684'; if MUNICIPALITY = '906' then MUNICIPALITY2 = '704';
if MUNICIPALITY = '633' then MUNICIPALITY2 = '729'; if MUNICIPALITY = '073' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '252' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '259' then MUNICIPALITY2 = '734';
if MUNICIPALITY = '308' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '501' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '586' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '587' then MUNICIPALITY2 = '734';
if MUNICIPALITY = '776' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '784' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '493' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '912' then MUNICIPALITY2 = '790';
if MUNICIPALITY = '988' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '741' then MUNICIPALITY2 = '740'; if MUNICIPALITY = '544' then MUNICIPALITY2 = '743'; if MUNICIPALITY = '975' then MUNICIPALITY2 = '743';
if MUNICIPALITY = '247' then MUNICIPALITY2 = '791'; if MUNICIPALITY = '603' then MUNICIPALITY2 = '791'; if MUNICIPALITY = '617' then MUNICIPALITY2 = '791'; if MUNICIPALITY = '682' then MUNICIPALITY2 = '791';
if MUNICIPALITY = '303' then MUNICIPALITY2 = '980'; if MUNICIPALITY = '095' then MUNICIPALITY2 = '208'; if MUNICIPALITY = '978' then MUNICIPALITY2 = '405'; if MUNICIPALITY = '424' then MUNICIPALITY2 = '434';
if MUNICIPALITY = '585' then MUNICIPALITY2 = '434'; if MUNICIPALITY = '701' then MUNICIPALITY2 = '434'; if MUNICIPALITY = '537' then MUNICIPALITY2 = '609'; if MUNICIPALITY = '310' then MUNICIPALITY2 = '020';
if MUNICIPALITY = '289' then MUNICIPALITY2 = '211'; if MUNICIPALITY = '227' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '916' then MUNICIPALITY2 = '402'; if MUNICIPALITY = '015' then MUNICIPALITY2 = '560';
if MUNICIPALITY = '559' then MUNICIPALITY2 = '946'; if MUNICIPALITY = '945' then MUNICIPALITY2 = '946'; if MUNICIPALITY = '863' then MUNICIPALITY2 = '010'; if MUNICIPALITY = '248' then MUNICIPALITY2 = '260';
if MUNICIPALITY = '534' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '223' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '540' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '696' then MUNICIPALITY2 = '491';
if MUNICIPALITY = '775' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '084' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '255' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '567' then MUNICIPALITY2 = '564';
if MUNICIPALITY = '972' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '926' then MUNICIPALITY2 = '678'; if MUNICIPALITY = '254' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '246' then MUNICIPALITY2 = '740';
if MUNICIPALITY = '618' then MUNICIPALITY2 = '740'; if MUNICIPALITY = '942' then MUNICIPALITY2 = '905'; if MUNICIPALITY = '476' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '838' then MUNICIPALITY2 = '423';
if MUNICIPALITY = '413' then MUNICIPALITY2 = '609'; if MUNICIPALITY = '283' then MUNICIPALITY2 = '098'; if MUNICIPALITY = '164' then MUNICIPALITY2 = '301'; if MUNICIPALITY = '532' then MUNICIPALITY2 = '398';
if MUNICIPALITY = '319' then MUNICIPALITY2 = '783'; if MUNICIPALITY = '442' then MUNICIPALITY2 = '051'; if MUNICIPALITY = '174' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '911' then MUNICIPALITY2 = '541';
if MUNICIPALITY = '099' then MUNICIPALITY2 = '214';


run;

* Saves data;

data lib100.demografiset_220524;
 set demografiset_2;
run;

* Data for 1971 to 1986;

data demografiset_71_86;
 set lib24.u0599_9_kaikki_akunta_71_86_s;
 ID = shnro;						
 YEAR = vuosi;
 MUNICIPALITY = kunta;				
 
* Adjustments due to the changes in municipalities during the sample period;

MUNICIPALITY2 = MUNICIPALITY;

if MUNICIPALITY = '096' then MUNICIPALITY2 = '050'; if MUNICIPALITY = '100' then MUNICIPALITY2 = '050'; if MUNICIPALITY = '141' then MUNICIPALITY2 = '140'; if MUNICIPALITY = '860' then MUNICIPALITY2 = '082';
if MUNICIPALITY = '502' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '786' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '144' then MUNICIPALITY2 = '143'; if MUNICIPALITY = '001' then MUNICIPALITY2 = '609';
if MUNICIPALITY = '840' then MUNICIPALITY2 = '837'; if MUNICIPALITY = '688' then MUNICIPALITY2 = '208'; if MUNICIPALITY = '242' then MUNICIPALITY2 = '320'; if MUNICIPALITY = '409' then MUNICIPALITY2 = '287';
if MUNICIPALITY = '750' then MUNICIPALITY2 = '287'; if MUNICIPALITY = '847' then MUNICIPALITY2 = '287'; if MUNICIPALITY = '695' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '597' then MUNICIPALITY2 = '422';
if MUNICIPALITY = '032' then MUNICIPALITY2 = '475'; if MUNICIPALITY = '590' then MUNICIPALITY2 = '475'; if MUNICIPALITY = '033' then MUNICIPALITY2 = '499'; if MUNICIPALITY = '270' then MUNICIPALITY2 = '499';
if MUNICIPALITY = '679' then MUNICIPALITY2 = '499'; if MUNICIPALITY = '769' then MUNICIPALITY2 = '499'; if MUNICIPALITY = '779' then MUNICIPALITY2 = '536'; if MUNICIPALITY = '542' then MUNICIPALITY2 = '541';
if MUNICIPALITY = '605' then MUNICIPALITY2 = '545'; if MUNICIPALITY = '974' then MUNICIPALITY2 = '545'; if MUNICIPALITY = '048' then MUNICIPALITY2 = '562'; if MUNICIPALITY = '735' then MUNICIPALITY2 = '678';
if MUNICIPALITY = '752' then MUNICIPALITY2 = '689'; if MUNICIPALITY = '575' then MUNICIPALITY2 = '748'; if MUNICIPALITY = '693' then MUNICIPALITY2 = '748'; if MUNICIPALITY = '789' then MUNICIPALITY2 = '740';
if MUNICIPALITY = '007' then MUNICIPALITY2 = '851'; if MUNICIPALITY = '229' then MUNICIPALITY2 = '851'; if MUNICIPALITY = '574' then MUNICIPALITY2 = '853'; if MUNICIPALITY = '788' then MUNICIPALITY2 = '908';
if MUNICIPALITY = '225' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '861' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '637' then MUNICIPALITY2 = '508'; if MUNICIPALITY = '070' then MUNICIPALITY2 = '285';
if MUNICIPALITY = '629' then MUNICIPALITY2 = '895'; if MUNICIPALITY = '012' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '754' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '166' then MUNICIPALITY2 = '893';
if MUNICIPALITY = '496' then MUNICIPALITY2 = '893'; if MUNICIPALITY = '894' then MUNICIPALITY2 = '893'; if MUNICIPALITY = '487' then MUNICIPALITY2 = '430'; if MUNICIPALITY = '852' then MUNICIPALITY2 = '536';
if MUNICIPALITY = '206' then MUNICIPALITY2 = '205'; if MUNICIPALITY = '203' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '201' then MUNICIPALITY2 = '285'; if MUNICIPALITY = '311' then MUNICIPALITY2 = '285';
if MUNICIPALITY = '222' then MUNICIPALITY2 = '503'; if MUNICIPALITY = '621' then MUNICIPALITY2 = '599'; if MUNICIPALITY = '990' then MUNICIPALITY2 = '599'; if MUNICIPALITY = '760' then MUNICIPALITY2 = '761';
if MUNICIPALITY = '756' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '836' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '034' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '622' then MUNICIPALITY2 = '444';
if MUNICIPALITY = '432' then MUNICIPALITY2 = '895'; if MUNICIPALITY = '238' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '253' then MUNICIPALITY2 = '790';

if MUNICIPALITY = '539' then MUNICIPALITY2 = '405'; if MUNICIPALITY = '787' then MUNICIPALITY2 = '179'; if MUNICIPALITY = '685' then MUNICIPALITY2 = '684'; if MUNICIPALITY = '842' then MUNICIPALITY2 = '710';
if MUNICIPALITY = '209' then MUNICIPALITY2 = '895'; if MUNICIPALITY = '274' then MUNICIPALITY2 = '992'; if MUNICIPALITY = '089' then MUNICIPALITY2 = '111'; if MUNICIPALITY = '088' then MUNICIPALITY2 = '111';
if MUNICIPALITY = '428' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '427' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '613' then MUNICIPALITY2 = '638'; if MUNICIPALITY = '612' then MUNICIPALITY2 = '638';
if MUNICIPALITY = '299' then MUNICIPALITY2 = '182'; if MUNICIPALITY = '014' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '492' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '841' then MUNICIPALITY2 = '859';
if MUNICIPALITY = '917' then MUNICIPALITY2 = '075'; if MUNICIPALITY = '582' then MUNICIPALITY2 = '678'; if MUNICIPALITY = '184' then MUNICIPALITY2 = '593'; if MUNICIPALITY = '594' then MUNICIPALITY2 = '593';
if MUNICIPALITY = '937' then MUNICIPALITY2 = '593'; if MUNICIPALITY = '640' then MUNICIPALITY2 = '593'; if MUNICIPALITY = '251' then MUNICIPALITY2 = '167'; if MUNICIPALITY = '856' then MUNICIPALITY2 = '167';
if MUNICIPALITY = '730' then MUNICIPALITY2 = '211'; if MUNICIPALITY = '919' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '431' then MUNICIPALITY2 = '430'; if MUNICIPALITY = '728' then MUNICIPALITY2 = '580';
if MUNICIPALITY = '891' then MUNICIPALITY2 = '580'; if MUNICIPALITY = '219' then MUNICIPALITY2 = '636'; if MUNICIPALITY = '589' then MUNICIPALITY2 = '743'; if MUNICIPALITY = '943' then MUNICIPALITY2 = '848';
if MUNICIPALITY = '293' then MUNICIPALITY2 = '886'; if MUNICIPALITY = '212' then MUNICIPALITY2 = '915'; if MUNICIPALITY = '699' then MUNICIPALITY2 = '698'; if MUNICIPALITY = '864' then MUNICIPALITY2 = '020';
if MUNICIPALITY = '928' then MUNICIPALITY2 = '020'; if MUNICIPALITY = '292' then MUNICIPALITY2 = '139'; if MUNICIPALITY = '443' then MUNICIPALITY2 = '182'; if MUNICIPALITY = '940' then MUNICIPALITY2 = '205';
if MUNICIPALITY = '085' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '490' then MUNICIPALITY2 = '503'; if MUNICIPALITY = '439' then MUNICIPALITY2 = '635'; if MUNICIPALITY = '266' then MUNICIPALITY2 = '684';
if MUNICIPALITY = '708' then MUNICIPALITY2 = '748'; if MUNICIPALITY = '772' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '479' then MUNICIPALITY2 = '946'; if MUNICIPALITY = '944' then MUNICIPALITY2 = '946';
if MUNICIPALITY = '932' then MUNICIPALITY2 = '980'; if MUNICIPALITY = '770' then MUNICIPALITY2 = '992'; if MUNICIPALITY = '774' then MUNICIPALITY2 = '992'; if MUNICIPALITY = '415' then MUNICIPALITY2 = '172';
if MUNICIPALITY = '414' then MUNICIPALITY2 = '005'; if MUNICIPALITY = '262' then MUNICIPALITY2 = '050'; if MUNICIPALITY = '913' then MUNICIPALITY2 = '102'; if MUNICIPALITY = '083' then MUNICIPALITY2 = '109';
if MUNICIPALITY = '210' then MUNICIPALITY2 = '109'; if MUNICIPALITY = '401' then MUNICIPALITY2 = '109'; if MUNICIPALITY = '692' then MUNICIPALITY2 = '109'; if MUNICIPALITY = '855' then MUNICIPALITY2 = '109';
if MUNICIPALITY = '045' then MUNICIPALITY2 = '167'; if MUNICIPALITY = '632' then MUNICIPALITY2 = '167'; if MUNICIPALITY = '180' then MUNICIPALITY2 = '179'; if MUNICIPALITY = '277' then MUNICIPALITY2 = '179';
if MUNICIPALITY = '183' then MUNICIPALITY2 = '182'; if MUNICIPALITY = '602' then MUNICIPALITY2 = '202'; if MUNICIPALITY = '004' then MUNICIPALITY2 = '233'; if MUNICIPALITY = '281' then MUNICIPALITY2 = '233';
if MUNICIPALITY = '971' then MUNICIPALITY2 = '233'; if MUNICIPALITY = '040' then MUNICIPALITY2 = '322'; if MUNICIPALITY = '243' then MUNICIPALITY2 = '322'; if MUNICIPALITY = '923' then MUNICIPALITY2 = '322';
if MUNICIPALITY = '315' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '429' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '885' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '754' then MUNICIPALITY2 = '286';
if MUNICIPALITY = '044' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '163' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '306' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '909' then MUNICIPALITY2 = '286';
if MUNICIPALITY = '175' then MUNICIPALITY2 = '301'; if MUNICIPALITY = '173' then MUNICIPALITY2 = '405'; if MUNICIPALITY = '737' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '006' then MUNICIPALITY2 = '430';
if MUNICIPALITY = '482' then MUNICIPALITY2 = '430'; if MUNICIPALITY = '101' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '150' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '279' then MUNICIPALITY2 = '445';
if MUNICIPALITY = '533' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '573' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '017' then MUNICIPALITY2 = '481'; if MUNICIPALITY = '419' then MUNICIPALITY2 = '481';
if MUNICIPALITY = '506' then MUNICIPALITY2 = '508'; if MUNICIPALITY = '933' then MUNICIPALITY2 = '508'; if MUNICIPALITY = '485' then MUNICIPALITY2 = '529'; if MUNICIPALITY = '705' then MUNICIPALITY2 = '529';
if MUNICIPALITY = '920' then MUNICIPALITY2 = '529'; if MUNICIPALITY = '973' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '979' then MUNICIPALITY2 = '636'; if MUNICIPALITY = '220' then MUNICIPALITY2 = '710';
if MUNICIPALITY = '606' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '835' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '406' then MUNICIPALITY2 = '684'; if MUNICIPALITY = '906' then MUNICIPALITY2 = '704';
if MUNICIPALITY = '633' then MUNICIPALITY2 = '729'; if MUNICIPALITY = '073' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '252' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '259' then MUNICIPALITY2 = '734';
if MUNICIPALITY = '308' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '501' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '586' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '587' then MUNICIPALITY2 = '734';
if MUNICIPALITY = '776' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '784' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '493' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '912' then MUNICIPALITY2 = '790';
if MUNICIPALITY = '988' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '741' then MUNICIPALITY2 = '740'; if MUNICIPALITY = '544' then MUNICIPALITY2 = '743'; if MUNICIPALITY = '975' then MUNICIPALITY2 = '743';
if MUNICIPALITY = '247' then MUNICIPALITY2 = '791'; if MUNICIPALITY = '603' then MUNICIPALITY2 = '791'; if MUNICIPALITY = '617' then MUNICIPALITY2 = '791'; if MUNICIPALITY = '682' then MUNICIPALITY2 = '791';
if MUNICIPALITY = '303' then MUNICIPALITY2 = '980'; if MUNICIPALITY = '095' then MUNICIPALITY2 = '208'; if MUNICIPALITY = '978' then MUNICIPALITY2 = '405'; if MUNICIPALITY = '424' then MUNICIPALITY2 = '434';
if MUNICIPALITY = '585' then MUNICIPALITY2 = '434'; if MUNICIPALITY = '701' then MUNICIPALITY2 = '434'; if MUNICIPALITY = '537' then MUNICIPALITY2 = '609'; if MUNICIPALITY = '310' then MUNICIPALITY2 = '020';
if MUNICIPALITY = '289' then MUNICIPALITY2 = '211'; if MUNICIPALITY = '227' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '916' then MUNICIPALITY2 = '402'; if MUNICIPALITY = '015' then MUNICIPALITY2 = '560';
if MUNICIPALITY = '559' then MUNICIPALITY2 = '946'; if MUNICIPALITY = '945' then MUNICIPALITY2 = '946'; if MUNICIPALITY = '863' then MUNICIPALITY2 = '010'; if MUNICIPALITY = '248' then MUNICIPALITY2 = '260';
if MUNICIPALITY = '534' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '223' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '540' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '696' then MUNICIPALITY2 = '491';
if MUNICIPALITY = '775' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '084' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '255' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '567' then MUNICIPALITY2 = '564';
if MUNICIPALITY = '972' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '926' then MUNICIPALITY2 = '678'; if MUNICIPALITY = '254' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '246' then MUNICIPALITY2 = '740';
if MUNICIPALITY = '618' then MUNICIPALITY2 = '740'; if MUNICIPALITY = '942' then MUNICIPALITY2 = '905'; if MUNICIPALITY = '476' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '838' then MUNICIPALITY2 = '423';
if MUNICIPALITY = '413' then MUNICIPALITY2 = '609'; if MUNICIPALITY = '283' then MUNICIPALITY2 = '098'; if MUNICIPALITY = '164' then MUNICIPALITY2 = '301'; if MUNICIPALITY = '532' then MUNICIPALITY2 = '398';
if MUNICIPALITY = '319' then MUNICIPALITY2 = '783'; if MUNICIPALITY = '442' then MUNICIPALITY2 = '051'; if MUNICIPALITY = '174' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '911' then MUNICIPALITY2 = '541';
if MUNICIPALITY = '099' then MUNICIPALITY2 = '214';

* Region;

if MUNICIPALITY2 = '049' or MUNICIPALITY2 = '078' or MUNICIPALITY2 = '091' or MUNICIPALITY2 = '106' or MUNICIPALITY2 = '186' or MUNICIPALITY2 = '235' or MUNICIPALITY2 = '245' or
MUNICIPALITY2 = '257' or MUNICIPALITY2 = '444' or MUNICIPALITY2 = '638' or MUNICIPALITY2 = '858' or MUNICIPALITY2 = '092' or MUNICIPALITY2 = '224' or MUNICIPALITY2 = '434' or
MUNICIPALITY2 = '505' or MUNICIPALITY2 = '543' or MUNICIPALITY2 = '710' or MUNICIPALITY2 = '753' or MUNICIPALITY2 = '927' or MUNICIPALITY2 = '018' or MUNICIPALITY2 = '149' or
MUNICIPALITY2 = '407' or MUNICIPALITY2 = '504' or MUNICIPALITY2 = '611' or MUNICIPALITY2 = '616' or MUNICIPALITY2 = '755' or MUNICIPALITY2 = '428' or MUNICIPALITY2 = '540' or
MUNICIPALITY2 = '220' or MUNICIPALITY2 = '223' or MUNICIPALITY2 = '424' or MUNICIPALITY2 = '427' or MUNICIPALITY2 = '585' or MUNICIPALITY2 = '606' or MUNICIPALITY2 = '612' or
MUNICIPALITY2 = '613' or MUNICIPALITY2 = '701' or MUNICIPALITY2 = '737' or MUNICIPALITY2 = '835' or MUNICIPALITY2 = '842' then MAAKUNTA = 1;

if MUNICIPALITY2 = '202' or MUNICIPALITY2 = '680' or MUNICIPALITY2 = '734' or MUNICIPALITY2 = '853' or MUNICIPALITY2 = '400' or MUNICIPALITY2 = '423' or MUNICIPALITY2 = '430' or
MUNICIPALITY2 = '481' or MUNICIPALITY2 = '503' or MUNICIPALITY2 = '529' or MUNICIPALITY2 = '577' or MUNICIPALITY2 = '445' or MUNICIPALITY2 = '895' or MUNICIPALITY2 = '019' or
MUNICIPALITY2 = '322' or MUNICIPALITY2 = '284' or MUNICIPALITY2 = '304' or MUNICIPALITY2 = '480' or MUNICIPALITY2 = '538' or MUNICIPALITY2 = '561' or MUNICIPALITY2 = '631' or
MUNICIPALITY2 = '636' or MUNICIPALITY2 = '704' or MUNICIPALITY2 = '738' or MUNICIPALITY2 = '761' or MUNICIPALITY2 = '833' or MUNICIPALITY2 = '918' or MUNICIPALITY2 = '040' or
MUNICIPALITY2 = '073' or MUNICIPALITY2 = '573' or MUNICIPALITY2 = '006' or MUNICIPALITY2 = '017' or MUNICIPALITY2 = '101' or MUNICIPALITY2 = '150' or MUNICIPALITY2 = '209' or
MUNICIPALITY2 = '219' or MUNICIPALITY2 = '243' or MUNICIPALITY2 = '252' or MUNICIPALITY2 = '259' or MUNICIPALITY2 = '279' or MUNICIPALITY2 = '308' or MUNICIPALITY2 = '419' or
MUNICIPALITY2 = '431' or MUNICIPALITY2 = '482' or MUNICIPALITY2 = '485' or MUNICIPALITY2 = '490' or MUNICIPALITY2 = '501' or MUNICIPALITY2 = '533' or MUNICIPALITY2 = '586' or
MUNICIPALITY2 = '587' or MUNICIPALITY2 = '602' or MUNICIPALITY2 = '705' or MUNICIPALITY2 = '776' or MUNICIPALITY2 = '784' or MUNICIPALITY2 = '838' or MUNICIPALITY2 = '906' or
MUNICIPALITY2 = '920' or MUNICIPALITY2 = '923' or MUNICIPALITY2 = '979' then MAAKUNTA = 2;

if MUNICIPALITY2 = '079' or MUNICIPALITY2 = '609' or MUNICIPALITY2 = '684' or MUNICIPALITY2 = '050' or MUNICIPALITY2 = '102' or MUNICIPALITY2 = '214' or MUNICIPALITY2 = '531' or
MUNICIPALITY2 = '886' or MUNICIPALITY2 = '051' or MUNICIPALITY2 = '099' or MUNICIPALITY2 = '181' or MUNICIPALITY2 = '230' or MUNICIPALITY2 = '271' or MUNICIPALITY2 = '319' or
MUNICIPALITY2 = '442' or MUNICIPALITY2 = '484' or MUNICIPALITY2 = '608' or MUNICIPALITY2 = '747' or MUNICIPALITY2 = '783' or MUNICIPALITY2 = '537' or MUNICIPALITY2 = '254' or
MUNICIPALITY2 = '262' or MUNICIPALITY2 = '266' or MUNICIPALITY2 = '293' or MUNICIPALITY2 = '406' or MUNICIPALITY2 = '413' or MUNICIPALITY2 = '685' or MUNICIPALITY2 = '913'
then MAAKUNTA = 4;

if MUNICIPALITY2 = '061' or MUNICIPALITY2 = '109' or MUNICIPALITY2 = '694' or MUNICIPALITY2 = '082' or MUNICIPALITY2 = '165' or MUNICIPALITY2 = '086' or MUNICIPALITY2 = '103' or
MUNICIPALITY2 = '169' or MUNICIPALITY2 = '433' or MUNICIPALITY2 = '834' or MUNICIPALITY2 = '981' or MUNICIPALITY2 = '083' or MUNICIPALITY2 = '210' or MUNICIPALITY2 = '401' or
MUNICIPALITY2 = '692' or MUNICIPALITY2 = '855' then MAAKUNTA = 5;

if MUNICIPALITY2 = '211' or MUNICIPALITY2 = '418' or MUNICIPALITY2 = '536' or MUNICIPALITY2 = '604' or MUNICIPALITY2 = '837' or MUNICIPALITY2 = '908' or MUNICIPALITY2 = '980' or
MUNICIPALITY2 = '020' or MUNICIPALITY2 = '108' or MUNICIPALITY2 = '508' or MUNICIPALITY2 = '562' or MUNICIPALITY2 = '581' or MUNICIPALITY2 = '790' or MUNICIPALITY2 = '143' or
MUNICIPALITY2 = '177' or MUNICIPALITY2 = '250' or MUNICIPALITY2 = '619' or MUNICIPALITY2 = '635' or MUNICIPALITY2 = '702' or MUNICIPALITY2 = '887' or MUNICIPALITY2 = '922' or
MUNICIPALITY2 = '936' or MUNICIPALITY2 = '864' or MUNICIPALITY2 = '310' or MUNICIPALITY2 = '289' or MUNICIPALITY2 = '299' or MUNICIPALITY2 = '303' or MUNICIPALITY2 = '439' or 
MUNICIPALITY2 = '443' or MUNICIPALITY2 = '493' or MUNICIPALITY2 = '506' or MUNICIPALITY2 = '730' or MUNICIPALITY2 = '772' or MUNICIPALITY2 = '864' or MUNICIPALITY2 = '912' or
MUNICIPALITY2 = '928' or MUNICIPALITY2 = '932' or MUNICIPALITY2 = '933' or MUNICIPALITY2 = '988' then MAAKUNTA = 6;

if MUNICIPALITY2 = '111' or MUNICIPALITY2 = '098' or MUNICIPALITY2 = '398' or MUNICIPALITY2 = '016' or MUNICIPALITY2 = '532' or MUNICIPALITY2 = '560' or MUNICIPALITY2 = '081' or
MUNICIPALITY2 = '283' or MUNICIPALITY2 = '316' or MUNICIPALITY2 = '576' or MUNICIPALITY2 = '781' or MUNICIPALITY2 = '015' or MUNICIPALITY2 = '088' or MUNICIPALITY2 = '089' then MAAKUNTA = 7;

if MUNICIPALITY2 = '075' or MUNICIPALITY2 = '285' or MUNICIPALITY2 = '286' or MUNICIPALITY2 = '142' or MUNICIPALITY2 = '489' or MUNICIPALITY2 = '624' or MUNICIPALITY2 = '935' or
MUNICIPALITY2 = '306' or MUNICIPALITY2 = '044' or MUNICIPALITY2 = '163' or MUNICIPALITY2 = '754' or MUNICIPALITY2 = '909' or MUNICIPALITY2 = '917' then MAAKUNTA = 8;

if MUNICIPALITY2 = '153' or MUNICIPALITY2 = '405' or MUNICIPALITY2 = '416' or MUNICIPALITY2 = '441' or MUNICIPALITY2 = '580' or MUNICIPALITY2 = '689' or MUNICIPALITY2 = '700' or
MUNICIPALITY2 = '739' or MUNICIPALITY2 = '831' or MUNICIPALITY2 = '173' or MUNICIPALITY2 = '539' or MUNICIPALITY2 = '728' or MUNICIPALITY2 = '775' or MUNICIPALITY2 = '891' or 
MUNICIPALITY2 = '978' then MAAKUNTA = 9;

if MUNICIPALITY2 = '491' or MUNICIPALITY2 = '740' or MUNICIPALITY2 = '507' or MUNICIPALITY2 = '593' or MUNICIPALITY2 = '046' or MUNICIPALITY2 = '090' or MUNICIPALITY2 = '097' or
MUNICIPALITY2 = '171' or MUNICIPALITY2 = '178' or MUNICIPALITY2 = '213' or MUNICIPALITY2 = '588' or MUNICIPALITY2 = '623' or MUNICIPALITY2 = '681' or MUNICIPALITY2 = '768' or 
MUNICIPALITY2 = '014' or MUNICIPALITY2 = '085' or MUNICIPALITY2 = '184' or MUNICIPALITY2 = '246' or MUNICIPALITY2 = '492' or MUNICIPALITY2 = '594' or MUNICIPALITY2 = '618' or
MUNICIPALITY2 = '640' or MUNICIPALITY2 = '696' or MUNICIPALITY2 = '741' or MUNICIPALITY2 = '937' then MAAKUNTA = 10;

if MUNICIPALITY2 = '140' or MUNICIPALITY2 = '297' or MUNICIPALITY2 = '915' or MUNICIPALITY2 = '749' or MUNICIPALITY2 = '778' or MUNICIPALITY2 = '174' or MUNICIPALITY2 = '204' or
MUNICIPALITY2 = '239' or MUNICIPALITY2 = '263' or MUNICIPALITY2 = '402' or MUNICIPALITY2 = '420' or MUNICIPALITY2 = '595' or MUNICIPALITY2 = '686' or MUNICIPALITY2 = '687' or
MUNICIPALITY2 = '762' or MUNICIPALITY2 = '844' or MUNICIPALITY2 = '857' or MUNICIPALITY2 = '921' or MUNICIPALITY2 = '925' or MUNICIPALITY2 = '227' or MUNICIPALITY2 = '212' or 
MUNICIPALITY2 = '476' or MUNICIPALITY2 = '534' or MUNICIPALITY2 = '916' or MUNICIPALITY2 = '919' then MAAKUNTA = 11;

if MUNICIPALITY2 = '167' or MUNICIPALITY2 = '276' or MUNICIPALITY2 = '422' or MUNICIPALITY2 = '541' or MUNICIPALITY2 = '309' or MUNICIPALITY2 = '146' or MUNICIPALITY2 = '176' or
MUNICIPALITY2 = '260' or MUNICIPALITY2 = '426' or MUNICIPALITY2 = '607' or MUNICIPALITY2 = '707' or MUNICIPALITY2 = '848' or MUNICIPALITY2 = '911' or MUNICIPALITY2 = '045' or 
MUNICIPALITY2 = '248' or MUNICIPALITY2 = '251' or MUNICIPALITY2 = '632' or MUNICIPALITY2 = '856' or MUNICIPALITY2 = '943' then MAAKUNTA = 12;

if MUNICIPALITY2 = '179' or MUNICIPALITY2 = '182' or MUNICIPALITY2 = '249' or MUNICIPALITY2 = '410' or MUNICIPALITY2 = '500' or MUNICIPALITY2 = '992' or MUNICIPALITY2 = '077' or
MUNICIPALITY2 = '172' or MUNICIPALITY2 = '216' or MUNICIPALITY2 = '226' or MUNICIPALITY2 = '256' or MUNICIPALITY2 = '265' or MUNICIPALITY2 = '275' or MUNICIPALITY2 = '291' or
MUNICIPALITY2 = '312' or MUNICIPALITY2 = '435' or MUNICIPALITY2 = '495' or MUNICIPALITY2 = '592' or MUNICIPALITY2 = '601' or MUNICIPALITY2 = '729' or MUNICIPALITY2 = '850' or
MUNICIPALITY2 = '892' or MUNICIPALITY2 = '931' or MUNICIPALITY2 = '787' or MUNICIPALITY2 = '180' or MUNICIPALITY2 = '183' or MUNICIPALITY2 = '274' or MUNICIPALITY2 = '277' or
MUNICIPALITY2 = '415' or MUNICIPALITY2 = '633' or MUNICIPALITY2 = '770' or MUNICIPALITY2 = '774' or MUNICIPALITY2 = '787' then MAAKUNTA = 13;

if MUNICIPALITY2 = '743' or MUNICIPALITY2 = '145' or MUNICIPALITY2 = '232' or MUNICIPALITY2 = '233' or MUNICIPALITY2 = '301' or MUNICIPALITY2 = '408' or MUNICIPALITY2 = '005' or
MUNICIPALITY2 = '010' or MUNICIPALITY2 = '052' or MUNICIPALITY2 = '151' or MUNICIPALITY2 = '164' or MUNICIPALITY2 = '218' or MUNICIPALITY2 = '300' or MUNICIPALITY2 = '403' or
MUNICIPALITY2 = '759' or MUNICIPALITY2 = '846' or MUNICIPALITY2 = '934' or MUNICIPALITY2 = '989' or MUNICIPALITY2 = '589' or MUNICIPALITY2 = '544' or MUNICIPALITY2 = '004' or 
MUNICIPALITY2 = '175' or MUNICIPALITY2 = '281' or MUNICIPALITY2 = '414' or MUNICIPALITY2 = '863' or MUNICIPALITY2 = '971' or MUNICIPALITY2 = '975' then MAAKUNTA = 14;

if MUNICIPALITY2 = '231' or MUNICIPALITY2 = '598' or MUNICIPALITY2 = '905' or MUNICIPALITY2 = '399' or MUNICIPALITY2 = '499' or MUNICIPALITY2 = '152' or MUNICIPALITY2 = '280' or
MUNICIPALITY2 = '287' or MUNICIPALITY2 = '288' or MUNICIPALITY2 = '440' or MUNICIPALITY2 = '475' or MUNICIPALITY2 = '545' or MUNICIPALITY2 = '599' or MUNICIPALITY2 = '893' or
MUNICIPALITY2 = '946' or MUNICIPALITY2 = '479' or MUNICIPALITY2 = '559' or MUNICIPALITY2 = '942' or MUNICIPALITY2 = '944' or MUNICIPALITY2 = '945' then MAAKUNTA = 15;

if MUNICIPALITY2 = '272' or MUNICIPALITY2 = '074' or MUNICIPALITY2 = '217' or MUNICIPALITY2 = '236' or MUNICIPALITY2 = '421' or MUNICIPALITY2 = '584' or MUNICIPALITY2 = '849' or
MUNICIPALITY2 = '924' or MUNICIPALITY2 = '315' or MUNICIPALITY2 = '429' or MUNICIPALITY2 = '885' then MAAKUNTA = 16;

if MUNICIPALITY2 = '244' or MUNICIPALITY2 = '564' or MUNICIPALITY2 = '678' or MUNICIPALITY2 = '069' or MUNICIPALITY2 = '139' or MUNICIPALITY2 = '208' or MUNICIPALITY2 = '305' or
MUNICIPALITY2 = '425' or MUNICIPALITY2 = '494' or MUNICIPALITY2 = '535' or MUNICIPALITY2 = '563' or MUNICIPALITY2 = '977' or MUNICIPALITY2 = '009' or MUNICIPALITY2 = '071' or
MUNICIPALITY2 = '072' or MUNICIPALITY2 = '317' or MUNICIPALITY2 = '436' or MUNICIPALITY2 = '483' or MUNICIPALITY2 = '615' or MUNICIPALITY2 = '625' or MUNICIPALITY2 = '626' or
MUNICIPALITY2 = '630' or MUNICIPALITY2 = '691' or MUNICIPALITY2 = '746' or MUNICIPALITY2 = '748' or MUNICIPALITY2 = '791' or MUNICIPALITY2 = '832' or MUNICIPALITY2 = '859' or
MUNICIPALITY2 = '889' or MUNICIPALITY2 = '926' or MUNICIPALITY2 = '255' or MUNICIPALITY2 = '084' or MUNICIPALITY2 = '095' or MUNICIPALITY2 = '247' or MUNICIPALITY2 = '292' or
MUNICIPALITY2 = '567' or MUNICIPALITY2 = '582' or MUNICIPALITY2 = '603' or MUNICIPALITY2 = '617' or MUNICIPALITY2 = '682' or MUNICIPALITY2 = '708' or MUNICIPALITY2 = '841' or
MUNICIPALITY2 = '972' or MUNICIPALITY2 = '973' then MAAKUNTA = 17;

if MUNICIPALITY2 = '205' or MUNICIPALITY2 = '290' or MUNICIPALITY2 = '777' or MUNICIPALITY2 = '105' or MUNICIPALITY2 = '578' or MUNICIPALITY2 = '620' or MUNICIPALITY2 = '697' or
MUNICIPALITY2 = '765' or MUNICIPALITY2 = '785' or MUNICIPALITY2 = '940' then MAAKUNTA = 18;

if MUNICIPALITY2 = '240' or MUNICIPALITY2 = '698' or MUNICIPALITY2 = '851' or MUNICIPALITY2 = '320' or MUNICIPALITY2 = '241' or MUNICIPALITY2 = '047' or MUNICIPALITY2 = '148' or
MUNICIPALITY2 = '261' or MUNICIPALITY2 = '273' or MUNICIPALITY2 = '498' or MUNICIPALITY2 = '583' or MUNICIPALITY2 = '854' or MUNICIPALITY2 = '614' or MUNICIPALITY2 = '683' or
MUNICIPALITY2 = '732' or MUNICIPALITY2 = '742' or MUNICIPALITY2 = '751' or MUNICIPALITY2 = '758' or MUNICIPALITY2 = '845' or MUNICIPALITY2 = '890' or MUNICIPALITY2 = '976' or
MUNICIPALITY2 = '699' then MAAKUNTA = 19;

if MUNICIPALITY2 = '478' or MUNICIPALITY2 = '035' or MUNICIPALITY2 = '043' or MUNICIPALITY2 = '060' or MUNICIPALITY2 = '062' or MUNICIPALITY2 = '065' or MUNICIPALITY2 = '076' or
MUNICIPALITY2 = '170' or MUNICIPALITY2 = '295' or MUNICIPALITY2 = '318' or MUNICIPALITY2 = '417' or MUNICIPALITY2 = '438' or MUNICIPALITY2 = '736' or MUNICIPALITY2 = '766' or
MUNICIPALITY2 = '771' or MUNICIPALITY2 = '941' then MAAKUNTA = 21;

 keep MAAKUNTA MUNICIPALITY2 ID YEAR;

run;

* Saves data;

data lib100.demografiset_71_86_240524;
 set demografiset_71_86;

run;

* Birth municipality;

data demografiset_syn;
 set lib24.u0599_9_kaikki_skunta_s;
 ID = shnro;						
 MUNICIPALITY = skunta;				
 
* Adjustments due to the changes in municipalities during the sample period;

MUNICIPALITY2 = MUNICIPALITY;

if MUNICIPALITY = '096' then MUNICIPALITY2 = '050'; if MUNICIPALITY = '100' then MUNICIPALITY2 = '050'; if MUNICIPALITY = '141' then MUNICIPALITY2 = '140'; if MUNICIPALITY = '860' then MUNICIPALITY2 = '082';
if MUNICIPALITY = '502' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '786' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '144' then MUNICIPALITY2 = '143'; if MUNICIPALITY = '001' then MUNICIPALITY2 = '609';
if MUNICIPALITY = '840' then MUNICIPALITY2 = '837'; if MUNICIPALITY = '688' then MUNICIPALITY2 = '208'; if MUNICIPALITY = '242' then MUNICIPALITY2 = '320'; if MUNICIPALITY = '409' then MUNICIPALITY2 = '287';
if MUNICIPALITY = '750' then MUNICIPALITY2 = '287'; if MUNICIPALITY = '847' then MUNICIPALITY2 = '287'; if MUNICIPALITY = '695' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '597' then MUNICIPALITY2 = '422';
if MUNICIPALITY = '032' then MUNICIPALITY2 = '475'; if MUNICIPALITY = '590' then MUNICIPALITY2 = '475'; if MUNICIPALITY = '033' then MUNICIPALITY2 = '499'; if MUNICIPALITY = '270' then MUNICIPALITY2 = '499';
if MUNICIPALITY = '679' then MUNICIPALITY2 = '499'; if MUNICIPALITY = '769' then MUNICIPALITY2 = '499'; if MUNICIPALITY = '779' then MUNICIPALITY2 = '536'; if MUNICIPALITY = '542' then MUNICIPALITY2 = '541';
if MUNICIPALITY = '605' then MUNICIPALITY2 = '545'; if MUNICIPALITY = '974' then MUNICIPALITY2 = '545'; if MUNICIPALITY = '048' then MUNICIPALITY2 = '562'; if MUNICIPALITY = '735' then MUNICIPALITY2 = '678';
if MUNICIPALITY = '752' then MUNICIPALITY2 = '689'; if MUNICIPALITY = '575' then MUNICIPALITY2 = '748'; if MUNICIPALITY = '693' then MUNICIPALITY2 = '748'; if MUNICIPALITY = '789' then MUNICIPALITY2 = '740';
if MUNICIPALITY = '007' then MUNICIPALITY2 = '851'; if MUNICIPALITY = '229' then MUNICIPALITY2 = '851'; if MUNICIPALITY = '574' then MUNICIPALITY2 = '853'; if MUNICIPALITY = '788' then MUNICIPALITY2 = '908';
if MUNICIPALITY = '225' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '861' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '637' then MUNICIPALITY2 = '508'; if MUNICIPALITY = '070' then MUNICIPALITY2 = '285';
if MUNICIPALITY = '629' then MUNICIPALITY2 = '895'; if MUNICIPALITY = '012' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '754' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '166' then MUNICIPALITY2 = '893';
if MUNICIPALITY = '496' then MUNICIPALITY2 = '893'; if MUNICIPALITY = '894' then MUNICIPALITY2 = '893'; if MUNICIPALITY = '487' then MUNICIPALITY2 = '430'; if MUNICIPALITY = '852' then MUNICIPALITY2 = '536';
if MUNICIPALITY = '206' then MUNICIPALITY2 = '205'; if MUNICIPALITY = '203' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '201' then MUNICIPALITY2 = '285'; if MUNICIPALITY = '311' then MUNICIPALITY2 = '285';
if MUNICIPALITY = '222' then MUNICIPALITY2 = '503'; if MUNICIPALITY = '621' then MUNICIPALITY2 = '599'; if MUNICIPALITY = '990' then MUNICIPALITY2 = '599'; if MUNICIPALITY = '760' then MUNICIPALITY2 = '761';
if MUNICIPALITY = '756' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '836' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '034' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '622' then MUNICIPALITY2 = '444';
if MUNICIPALITY = '432' then MUNICIPALITY2 = '895'; if MUNICIPALITY = '238' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '253' then MUNICIPALITY2 = '790';

if MUNICIPALITY = '539' then MUNICIPALITY2 = '405'; if MUNICIPALITY = '787' then MUNICIPALITY2 = '179'; if MUNICIPALITY = '685' then MUNICIPALITY2 = '684'; if MUNICIPALITY = '842' then MUNICIPALITY2 = '710';
if MUNICIPALITY = '209' then MUNICIPALITY2 = '895'; if MUNICIPALITY = '274' then MUNICIPALITY2 = '992'; if MUNICIPALITY = '089' then MUNICIPALITY2 = '111'; if MUNICIPALITY = '088' then MUNICIPALITY2 = '111';
if MUNICIPALITY = '428' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '427' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '613' then MUNICIPALITY2 = '638'; if MUNICIPALITY = '612' then MUNICIPALITY2 = '638';
if MUNICIPALITY = '299' then MUNICIPALITY2 = '182'; if MUNICIPALITY = '014' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '492' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '841' then MUNICIPALITY2 = '859';
if MUNICIPALITY = '917' then MUNICIPALITY2 = '075'; if MUNICIPALITY = '582' then MUNICIPALITY2 = '678'; if MUNICIPALITY = '184' then MUNICIPALITY2 = '593'; if MUNICIPALITY = '594' then MUNICIPALITY2 = '593';
if MUNICIPALITY = '937' then MUNICIPALITY2 = '593'; if MUNICIPALITY = '640' then MUNICIPALITY2 = '593'; if MUNICIPALITY = '251' then MUNICIPALITY2 = '167'; if MUNICIPALITY = '856' then MUNICIPALITY2 = '167';
if MUNICIPALITY = '730' then MUNICIPALITY2 = '211'; if MUNICIPALITY = '919' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '431' then MUNICIPALITY2 = '430'; if MUNICIPALITY = '728' then MUNICIPALITY2 = '580';
if MUNICIPALITY = '891' then MUNICIPALITY2 = '580'; if MUNICIPALITY = '219' then MUNICIPALITY2 = '636'; if MUNICIPALITY = '589' then MUNICIPALITY2 = '743'; if MUNICIPALITY = '943' then MUNICIPALITY2 = '848';
if MUNICIPALITY = '293' then MUNICIPALITY2 = '886'; if MUNICIPALITY = '212' then MUNICIPALITY2 = '915'; if MUNICIPALITY = '699' then MUNICIPALITY2 = '698'; if MUNICIPALITY = '864' then MUNICIPALITY2 = '020';
if MUNICIPALITY = '928' then MUNICIPALITY2 = '020'; if MUNICIPALITY = '292' then MUNICIPALITY2 = '139'; if MUNICIPALITY = '443' then MUNICIPALITY2 = '182'; if MUNICIPALITY = '940' then MUNICIPALITY2 = '205';
if MUNICIPALITY = '085' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '490' then MUNICIPALITY2 = '503'; if MUNICIPALITY = '439' then MUNICIPALITY2 = '635'; if MUNICIPALITY = '266' then MUNICIPALITY2 = '684';
if MUNICIPALITY = '708' then MUNICIPALITY2 = '748'; if MUNICIPALITY = '772' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '479' then MUNICIPALITY2 = '946'; if MUNICIPALITY = '944' then MUNICIPALITY2 = '946';
if MUNICIPALITY = '932' then MUNICIPALITY2 = '980'; if MUNICIPALITY = '770' then MUNICIPALITY2 = '992'; if MUNICIPALITY = '774' then MUNICIPALITY2 = '992'; if MUNICIPALITY = '415' then MUNICIPALITY2 = '172';
if MUNICIPALITY = '414' then MUNICIPALITY2 = '005'; if MUNICIPALITY = '262' then MUNICIPALITY2 = '050'; if MUNICIPALITY = '913' then MUNICIPALITY2 = '102'; if MUNICIPALITY = '083' then MUNICIPALITY2 = '109';
if MUNICIPALITY = '210' then MUNICIPALITY2 = '109'; if MUNICIPALITY = '401' then MUNICIPALITY2 = '109'; if MUNICIPALITY = '692' then MUNICIPALITY2 = '109'; if MUNICIPALITY = '855' then MUNICIPALITY2 = '109';
if MUNICIPALITY = '045' then MUNICIPALITY2 = '167'; if MUNICIPALITY = '632' then MUNICIPALITY2 = '167'; if MUNICIPALITY = '180' then MUNICIPALITY2 = '179'; if MUNICIPALITY = '277' then MUNICIPALITY2 = '179';
if MUNICIPALITY = '183' then MUNICIPALITY2 = '182'; if MUNICIPALITY = '602' then MUNICIPALITY2 = '202'; if MUNICIPALITY = '004' then MUNICIPALITY2 = '233'; if MUNICIPALITY = '281' then MUNICIPALITY2 = '233';
if MUNICIPALITY = '971' then MUNICIPALITY2 = '233'; if MUNICIPALITY = '040' then MUNICIPALITY2 = '322'; if MUNICIPALITY = '243' then MUNICIPALITY2 = '322'; if MUNICIPALITY = '923' then MUNICIPALITY2 = '322';
if MUNICIPALITY = '315' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '429' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '885' then MUNICIPALITY2 = '272'; if MUNICIPALITY = '754' then MUNICIPALITY2 = '286';
if MUNICIPALITY = '044' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '163' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '306' then MUNICIPALITY2 = '286'; if MUNICIPALITY = '909' then MUNICIPALITY2 = '286';
if MUNICIPALITY = '175' then MUNICIPALITY2 = '301'; if MUNICIPALITY = '173' then MUNICIPALITY2 = '405'; if MUNICIPALITY = '737' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '006' then MUNICIPALITY2 = '430';
if MUNICIPALITY = '482' then MUNICIPALITY2 = '430'; if MUNICIPALITY = '101' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '150' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '279' then MUNICIPALITY2 = '445';
if MUNICIPALITY = '533' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '573' then MUNICIPALITY2 = '445'; if MUNICIPALITY = '017' then MUNICIPALITY2 = '481'; if MUNICIPALITY = '419' then MUNICIPALITY2 = '481';
if MUNICIPALITY = '506' then MUNICIPALITY2 = '508'; if MUNICIPALITY = '933' then MUNICIPALITY2 = '508'; if MUNICIPALITY = '485' then MUNICIPALITY2 = '529'; if MUNICIPALITY = '705' then MUNICIPALITY2 = '529';
if MUNICIPALITY = '920' then MUNICIPALITY2 = '529'; if MUNICIPALITY = '973' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '979' then MUNICIPALITY2 = '636'; if MUNICIPALITY = '220' then MUNICIPALITY2 = '710';
if MUNICIPALITY = '606' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '835' then MUNICIPALITY2 = '710'; if MUNICIPALITY = '406' then MUNICIPALITY2 = '684'; if MUNICIPALITY = '906' then MUNICIPALITY2 = '704';
if MUNICIPALITY = '633' then MUNICIPALITY2 = '729'; if MUNICIPALITY = '073' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '252' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '259' then MUNICIPALITY2 = '734';
if MUNICIPALITY = '308' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '501' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '586' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '587' then MUNICIPALITY2 = '734';
if MUNICIPALITY = '776' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '784' then MUNICIPALITY2 = '734'; if MUNICIPALITY = '493' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '912' then MUNICIPALITY2 = '790';
if MUNICIPALITY = '988' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '741' then MUNICIPALITY2 = '740'; if MUNICIPALITY = '544' then MUNICIPALITY2 = '743'; if MUNICIPALITY = '975' then MUNICIPALITY2 = '743';
if MUNICIPALITY = '247' then MUNICIPALITY2 = '791'; if MUNICIPALITY = '603' then MUNICIPALITY2 = '791'; if MUNICIPALITY = '617' then MUNICIPALITY2 = '791'; if MUNICIPALITY = '682' then MUNICIPALITY2 = '791';
if MUNICIPALITY = '303' then MUNICIPALITY2 = '980'; if MUNICIPALITY = '095' then MUNICIPALITY2 = '208'; if MUNICIPALITY = '978' then MUNICIPALITY2 = '405'; if MUNICIPALITY = '424' then MUNICIPALITY2 = '434';
if MUNICIPALITY = '585' then MUNICIPALITY2 = '434'; if MUNICIPALITY = '701' then MUNICIPALITY2 = '434'; if MUNICIPALITY = '537' then MUNICIPALITY2 = '609'; if MUNICIPALITY = '310' then MUNICIPALITY2 = '020';
if MUNICIPALITY = '289' then MUNICIPALITY2 = '211'; if MUNICIPALITY = '227' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '916' then MUNICIPALITY2 = '402'; if MUNICIPALITY = '015' then MUNICIPALITY2 = '560';
if MUNICIPALITY = '559' then MUNICIPALITY2 = '946'; if MUNICIPALITY = '945' then MUNICIPALITY2 = '946'; if MUNICIPALITY = '863' then MUNICIPALITY2 = '010'; if MUNICIPALITY = '248' then MUNICIPALITY2 = '260';
if MUNICIPALITY = '534' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '223' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '540' then MUNICIPALITY2 = '444'; if MUNICIPALITY = '696' then MUNICIPALITY2 = '491';
if MUNICIPALITY = '775' then MUNICIPALITY2 = '491'; if MUNICIPALITY = '084' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '255' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '567' then MUNICIPALITY2 = '564';
if MUNICIPALITY = '972' then MUNICIPALITY2 = '564'; if MUNICIPALITY = '926' then MUNICIPALITY2 = '678'; if MUNICIPALITY = '254' then MUNICIPALITY2 = '790'; if MUNICIPALITY = '246' then MUNICIPALITY2 = '740';
if MUNICIPALITY = '618' then MUNICIPALITY2 = '740'; if MUNICIPALITY = '942' then MUNICIPALITY2 = '905'; if MUNICIPALITY = '476' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '838' then MUNICIPALITY2 = '423';
if MUNICIPALITY = '413' then MUNICIPALITY2 = '609'; if MUNICIPALITY = '283' then MUNICIPALITY2 = '098'; if MUNICIPALITY = '164' then MUNICIPALITY2 = '301'; if MUNICIPALITY = '532' then MUNICIPALITY2 = '398';
if MUNICIPALITY = '319' then MUNICIPALITY2 = '783'; if MUNICIPALITY = '442' then MUNICIPALITY2 = '051'; if MUNICIPALITY = '174' then MUNICIPALITY2 = '297'; if MUNICIPALITY = '911' then MUNICIPALITY2 = '541';
if MUNICIPALITY = '099' then MUNICIPALITY2 = '214';

* Regions;

if MUNICIPALITY2 = '049' or MUNICIPALITY2 = '078' or MUNICIPALITY2 = '091' or MUNICIPALITY2 = '106' or MUNICIPALITY2 = '186' or MUNICIPALITY2 = '235' or MUNICIPALITY2 = '245' or
MUNICIPALITY2 = '257' or MUNICIPALITY2 = '444' or MUNICIPALITY2 = '638' or MUNICIPALITY2 = '858' or MUNICIPALITY2 = '092' or MUNICIPALITY2 = '224' or MUNICIPALITY2 = '434' or
MUNICIPALITY2 = '505' or MUNICIPALITY2 = '543' or MUNICIPALITY2 = '710' or MUNICIPALITY2 = '753' or MUNICIPALITY2 = '927' or MUNICIPALITY2 = '018' or MUNICIPALITY2 = '149' or
MUNICIPALITY2 = '407' or MUNICIPALITY2 = '504' or MUNICIPALITY2 = '611' or MUNICIPALITY2 = '616' or MUNICIPALITY2 = '755' or MUNICIPALITY2 = '428' or MUNICIPALITY2 = '540' or
MUNICIPALITY2 = '220' or MUNICIPALITY2 = '223' or MUNICIPALITY2 = '424' or MUNICIPALITY2 = '427' or MUNICIPALITY2 = '585' or MUNICIPALITY2 = '606' or MUNICIPALITY2 = '612' or
MUNICIPALITY2 = '613' or MUNICIPALITY2 = '701' or MUNICIPALITY2 = '737' or MUNICIPALITY2 = '835' or MUNICIPALITY2 = '842' then MAAKUNTA = 1;

if MUNICIPALITY2 = '202' or MUNICIPALITY2 = '680' or MUNICIPALITY2 = '734' or MUNICIPALITY2 = '853' or MUNICIPALITY2 = '400' or MUNICIPALITY2 = '423' or MUNICIPALITY2 = '430' or
MUNICIPALITY2 = '481' or MUNICIPALITY2 = '503' or MUNICIPALITY2 = '529' or MUNICIPALITY2 = '577' or MUNICIPALITY2 = '445' or MUNICIPALITY2 = '895' or MUNICIPALITY2 = '019' or
MUNICIPALITY2 = '322' or MUNICIPALITY2 = '284' or MUNICIPALITY2 = '304' or MUNICIPALITY2 = '480' or MUNICIPALITY2 = '538' or MUNICIPALITY2 = '561' or MUNICIPALITY2 = '631' or
MUNICIPALITY2 = '636' or MUNICIPALITY2 = '704' or MUNICIPALITY2 = '738' or MUNICIPALITY2 = '761' or MUNICIPALITY2 = '833' or MUNICIPALITY2 = '918' or MUNICIPALITY2 = '040' or
MUNICIPALITY2 = '073' or MUNICIPALITY2 = '573' or MUNICIPALITY2 = '006' or MUNICIPALITY2 = '017' or MUNICIPALITY2 = '101' or MUNICIPALITY2 = '150' or MUNICIPALITY2 = '209' or
MUNICIPALITY2 = '219' or MUNICIPALITY2 = '243' or MUNICIPALITY2 = '252' or MUNICIPALITY2 = '259' or MUNICIPALITY2 = '279' or MUNICIPALITY2 = '308' or MUNICIPALITY2 = '419' or
MUNICIPALITY2 = '431' or MUNICIPALITY2 = '482' or MUNICIPALITY2 = '485' or MUNICIPALITY2 = '490' or MUNICIPALITY2 = '501' or MUNICIPALITY2 = '533' or MUNICIPALITY2 = '586' or
MUNICIPALITY2 = '587' or MUNICIPALITY2 = '602' or MUNICIPALITY2 = '705' or MUNICIPALITY2 = '776' or MUNICIPALITY2 = '784' or MUNICIPALITY2 = '838' or MUNICIPALITY2 = '906' or
MUNICIPALITY2 = '920' or MUNICIPALITY2 = '923' or MUNICIPALITY2 = '979' then MAAKUNTA = 2;

if MUNICIPALITY2 = '079' or MUNICIPALITY2 = '609' or MUNICIPALITY2 = '684' or MUNICIPALITY2 = '050' or MUNICIPALITY2 = '102' or MUNICIPALITY2 = '214' or MUNICIPALITY2 = '531' or
MUNICIPALITY2 = '886' or MUNICIPALITY2 = '051' or MUNICIPALITY2 = '099' or MUNICIPALITY2 = '181' or MUNICIPALITY2 = '230' or MUNICIPALITY2 = '271' or MUNICIPALITY2 = '319' or
MUNICIPALITY2 = '442' or MUNICIPALITY2 = '484' or MUNICIPALITY2 = '608' or MUNICIPALITY2 = '747' or MUNICIPALITY2 = '783' or MUNICIPALITY2 = '537' or MUNICIPALITY2 = '254' or
MUNICIPALITY2 = '262' or MUNICIPALITY2 = '266' or MUNICIPALITY2 = '293' or MUNICIPALITY2 = '406' or MUNICIPALITY2 = '413' or MUNICIPALITY2 = '685' or MUNICIPALITY2 = '913'
then MAAKUNTA = 4;

if MUNICIPALITY2 = '061' or MUNICIPALITY2 = '109' or MUNICIPALITY2 = '694' or MUNICIPALITY2 = '082' or MUNICIPALITY2 = '165' or MUNICIPALITY2 = '086' or MUNICIPALITY2 = '103' or
MUNICIPALITY2 = '169' or MUNICIPALITY2 = '433' or MUNICIPALITY2 = '834' or MUNICIPALITY2 = '981' or MUNICIPALITY2 = '083' or MUNICIPALITY2 = '210' or MUNICIPALITY2 = '401' or
MUNICIPALITY2 = '692' or MUNICIPALITY2 = '855' then MAAKUNTA = 5;

if MUNICIPALITY2 = '211' or MUNICIPALITY2 = '418' or MUNICIPALITY2 = '536' or MUNICIPALITY2 = '604' or MUNICIPALITY2 = '837' or MUNICIPALITY2 = '908' or MUNICIPALITY2 = '980' or
MUNICIPALITY2 = '020' or MUNICIPALITY2 = '108' or MUNICIPALITY2 = '508' or MUNICIPALITY2 = '562' or MUNICIPALITY2 = '581' or MUNICIPALITY2 = '790' or MUNICIPALITY2 = '143' or
MUNICIPALITY2 = '177' or MUNICIPALITY2 = '250' or MUNICIPALITY2 = '619' or MUNICIPALITY2 = '635' or MUNICIPALITY2 = '702' or MUNICIPALITY2 = '887' or MUNICIPALITY2 = '922' or
MUNICIPALITY2 = '936' or MUNICIPALITY2 = '864' or MUNICIPALITY2 = '310' or MUNICIPALITY2 = '289' or MUNICIPALITY2 = '299' or MUNICIPALITY2 = '303' or MUNICIPALITY2 = '439' or 
MUNICIPALITY2 = '443' or MUNICIPALITY2 = '493' or MUNICIPALITY2 = '506' or MUNICIPALITY2 = '730' or MUNICIPALITY2 = '772' or MUNICIPALITY2 = '864' or MUNICIPALITY2 = '912' or
MUNICIPALITY2 = '928' or MUNICIPALITY2 = '932' or MUNICIPALITY2 = '933' or MUNICIPALITY2 = '988' then MAAKUNTA = 6;

if MUNICIPALITY2 = '111' or MUNICIPALITY2 = '098' or MUNICIPALITY2 = '398' or MUNICIPALITY2 = '016' or MUNICIPALITY2 = '532' or MUNICIPALITY2 = '560' or MUNICIPALITY2 = '081' or
MUNICIPALITY2 = '283' or MUNICIPALITY2 = '316' or MUNICIPALITY2 = '576' or MUNICIPALITY2 = '781' or MUNICIPALITY2 = '015' or MUNICIPALITY2 = '088' or MUNICIPALITY2 = '089' then MAAKUNTA = 7;

if MUNICIPALITY2 = '075' or MUNICIPALITY2 = '285' or MUNICIPALITY2 = '286' or MUNICIPALITY2 = '142' or MUNICIPALITY2 = '489' or MUNICIPALITY2 = '624' or MUNICIPALITY2 = '935' or
MUNICIPALITY2 = '306' or MUNICIPALITY2 = '044' or MUNICIPALITY2 = '163' or MUNICIPALITY2 = '754' or MUNICIPALITY2 = '909' or MUNICIPALITY2 = '917' then MAAKUNTA = 8;

if MUNICIPALITY2 = '153' or MUNICIPALITY2 = '405' or MUNICIPALITY2 = '416' or MUNICIPALITY2 = '441' or MUNICIPALITY2 = '580' or MUNICIPALITY2 = '689' or MUNICIPALITY2 = '700' or
MUNICIPALITY2 = '739' or MUNICIPALITY2 = '831' or MUNICIPALITY2 = '173' or MUNICIPALITY2 = '539' or MUNICIPALITY2 = '728' or MUNICIPALITY2 = '775' or MUNICIPALITY2 = '891' or 
MUNICIPALITY2 = '978' then MAAKUNTA = 9;

if MUNICIPALITY2 = '491' or MUNICIPALITY2 = '740' or MUNICIPALITY2 = '507' or MUNICIPALITY2 = '593' or MUNICIPALITY2 = '046' or MUNICIPALITY2 = '090' or MUNICIPALITY2 = '097' or
MUNICIPALITY2 = '171' or MUNICIPALITY2 = '178' or MUNICIPALITY2 = '213' or MUNICIPALITY2 = '588' or MUNICIPALITY2 = '623' or MUNICIPALITY2 = '681' or MUNICIPALITY2 = '768' or 
MUNICIPALITY2 = '014' or MUNICIPALITY2 = '085' or MUNICIPALITY2 = '184' or MUNICIPALITY2 = '246' or MUNICIPALITY2 = '492' or MUNICIPALITY2 = '594' or MUNICIPALITY2 = '618' or
MUNICIPALITY2 = '640' or MUNICIPALITY2 = '696' or MUNICIPALITY2 = '741' or MUNICIPALITY2 = '937' then MAAKUNTA = 10;

if MUNICIPALITY2 = '140' or MUNICIPALITY2 = '297' or MUNICIPALITY2 = '915' or MUNICIPALITY2 = '749' or MUNICIPALITY2 = '778' or MUNICIPALITY2 = '174' or MUNICIPALITY2 = '204' or
MUNICIPALITY2 = '239' or MUNICIPALITY2 = '263' or MUNICIPALITY2 = '402' or MUNICIPALITY2 = '420' or MUNICIPALITY2 = '595' or MUNICIPALITY2 = '686' or MUNICIPALITY2 = '687' or
MUNICIPALITY2 = '762' or MUNICIPALITY2 = '844' or MUNICIPALITY2 = '857' or MUNICIPALITY2 = '921' or MUNICIPALITY2 = '925' or MUNICIPALITY2 = '227' or MUNICIPALITY2 = '212' or 
MUNICIPALITY2 = '476' or MUNICIPALITY2 = '534' or MUNICIPALITY2 = '916' or MUNICIPALITY2 = '919' then MAAKUNTA = 11;

if MUNICIPALITY2 = '167' or MUNICIPALITY2 = '276' or MUNICIPALITY2 = '422' or MUNICIPALITY2 = '541' or MUNICIPALITY2 = '309' or MUNICIPALITY2 = '146' or MUNICIPALITY2 = '176' or
MUNICIPALITY2 = '260' or MUNICIPALITY2 = '426' or MUNICIPALITY2 = '607' or MUNICIPALITY2 = '707' or MUNICIPALITY2 = '848' or MUNICIPALITY2 = '911' or MUNICIPALITY2 = '045' or 
MUNICIPALITY2 = '248' or MUNICIPALITY2 = '251' or MUNICIPALITY2 = '632' or MUNICIPALITY2 = '856' or MUNICIPALITY2 = '943' then MAAKUNTA = 12;

if MUNICIPALITY2 = '179' or MUNICIPALITY2 = '182' or MUNICIPALITY2 = '249' or MUNICIPALITY2 = '410' or MUNICIPALITY2 = '500' or MUNICIPALITY2 = '992' or MUNICIPALITY2 = '077' or
MUNICIPALITY2 = '172' or MUNICIPALITY2 = '216' or MUNICIPALITY2 = '226' or MUNICIPALITY2 = '256' or MUNICIPALITY2 = '265' or MUNICIPALITY2 = '275' or MUNICIPALITY2 = '291' or
MUNICIPALITY2 = '312' or MUNICIPALITY2 = '435' or MUNICIPALITY2 = '495' or MUNICIPALITY2 = '592' or MUNICIPALITY2 = '601' or MUNICIPALITY2 = '729' or MUNICIPALITY2 = '850' or
MUNICIPALITY2 = '892' or MUNICIPALITY2 = '931' or MUNICIPALITY2 = '787' or MUNICIPALITY2 = '180' or MUNICIPALITY2 = '183' or MUNICIPALITY2 = '274' or MUNICIPALITY2 = '277' or
MUNICIPALITY2 = '415' or MUNICIPALITY2 = '633' or MUNICIPALITY2 = '770' or MUNICIPALITY2 = '774' or MUNICIPALITY2 = '787' then MAAKUNTA = 13;

if MUNICIPALITY2 = '743' or MUNICIPALITY2 = '145' or MUNICIPALITY2 = '232' or MUNICIPALITY2 = '233' or MUNICIPALITY2 = '301' or MUNICIPALITY2 = '408' or MUNICIPALITY2 = '005' or
MUNICIPALITY2 = '010' or MUNICIPALITY2 = '052' or MUNICIPALITY2 = '151' or MUNICIPALITY2 = '164' or MUNICIPALITY2 = '218' or MUNICIPALITY2 = '300' or MUNICIPALITY2 = '403' or
MUNICIPALITY2 = '759' or MUNICIPALITY2 = '846' or MUNICIPALITY2 = '934' or MUNICIPALITY2 = '989' or MUNICIPALITY2 = '589' or MUNICIPALITY2 = '544' or MUNICIPALITY2 = '004' or 
MUNICIPALITY2 = '175' or MUNICIPALITY2 = '281' or MUNICIPALITY2 = '414' or MUNICIPALITY2 = '863' or MUNICIPALITY2 = '971' or MUNICIPALITY2 = '975' then MAAKUNTA = 14;

if MUNICIPALITY2 = '231' or MUNICIPALITY2 = '598' or MUNICIPALITY2 = '905' or MUNICIPALITY2 = '399' or MUNICIPALITY2 = '499' or MUNICIPALITY2 = '152' or MUNICIPALITY2 = '280' or
MUNICIPALITY2 = '287' or MUNICIPALITY2 = '288' or MUNICIPALITY2 = '440' or MUNICIPALITY2 = '475' or MUNICIPALITY2 = '545' or MUNICIPALITY2 = '599' or MUNICIPALITY2 = '893' or
MUNICIPALITY2 = '946' or MUNICIPALITY2 = '479' or MUNICIPALITY2 = '559' or MUNICIPALITY2 = '942' or MUNICIPALITY2 = '944' or MUNICIPALITY2 = '945' then MAAKUNTA = 15;

if MUNICIPALITY2 = '272' or MUNICIPALITY2 = '074' or MUNICIPALITY2 = '217' or MUNICIPALITY2 = '236' or MUNICIPALITY2 = '421' or MUNICIPALITY2 = '584' or MUNICIPALITY2 = '849' or
MUNICIPALITY2 = '924' or MUNICIPALITY2 = '315' or MUNICIPALITY2 = '429' or MUNICIPALITY2 = '885' then MAAKUNTA = 16;

if MUNICIPALITY2 = '244' or MUNICIPALITY2 = '564' or MUNICIPALITY2 = '678' or MUNICIPALITY2 = '069' or MUNICIPALITY2 = '139' or MUNICIPALITY2 = '208' or MUNICIPALITY2 = '305' or
MUNICIPALITY2 = '425' or MUNICIPALITY2 = '494' or MUNICIPALITY2 = '535' or MUNICIPALITY2 = '563' or MUNICIPALITY2 = '977' or MUNICIPALITY2 = '009' or MUNICIPALITY2 = '071' or
MUNICIPALITY2 = '072' or MUNICIPALITY2 = '317' or MUNICIPALITY2 = '436' or MUNICIPALITY2 = '483' or MUNICIPALITY2 = '615' or MUNICIPALITY2 = '625' or MUNICIPALITY2 = '626' or
MUNICIPALITY2 = '630' or MUNICIPALITY2 = '691' or MUNICIPALITY2 = '746' or MUNICIPALITY2 = '748' or MUNICIPALITY2 = '791' or MUNICIPALITY2 = '832' or MUNICIPALITY2 = '859' or
MUNICIPALITY2 = '889' or MUNICIPALITY2 = '926' or MUNICIPALITY2 = '255' or MUNICIPALITY2 = '084' or MUNICIPALITY2 = '095' or MUNICIPALITY2 = '247' or MUNICIPALITY2 = '292' or
MUNICIPALITY2 = '567' or MUNICIPALITY2 = '582' or MUNICIPALITY2 = '603' or MUNICIPALITY2 = '617' or MUNICIPALITY2 = '682' or MUNICIPALITY2 = '708' or MUNICIPALITY2 = '841' or
MUNICIPALITY2 = '972' or MUNICIPALITY2 = '973' then MAAKUNTA = 17;

if MUNICIPALITY2 = '205' or MUNICIPALITY2 = '290' or MUNICIPALITY2 = '777' or MUNICIPALITY2 = '105' or MUNICIPALITY2 = '578' or MUNICIPALITY2 = '620' or MUNICIPALITY2 = '697' or
MUNICIPALITY2 = '765' or MUNICIPALITY2 = '785' or MUNICIPALITY2 = '940' then MAAKUNTA = 18;

if MUNICIPALITY2 = '240' or MUNICIPALITY2 = '698' or MUNICIPALITY2 = '851' or MUNICIPALITY2 = '320' or MUNICIPALITY2 = '241' or MUNICIPALITY2 = '047' or MUNICIPALITY2 = '148' or
MUNICIPALITY2 = '261' or MUNICIPALITY2 = '273' or MUNICIPALITY2 = '498' or MUNICIPALITY2 = '583' or MUNICIPALITY2 = '854' or MUNICIPALITY2 = '614' or MUNICIPALITY2 = '683' or
MUNICIPALITY2 = '732' or MUNICIPALITY2 = '742' or MUNICIPALITY2 = '751' or MUNICIPALITY2 = '758' or MUNICIPALITY2 = '845' or MUNICIPALITY2 = '890' or MUNICIPALITY2 = '976' or
MUNICIPALITY2 = '699' then MAAKUNTA = 19;

if MUNICIPALITY2 = '478' or MUNICIPALITY2 = '035' or MUNICIPALITY2 = '043' or MUNICIPALITY2 = '060' or MUNICIPALITY2 = '062' or MUNICIPALITY2 = '065' or MUNICIPALITY2 = '076' or
MUNICIPALITY2 = '170' or MUNICIPALITY2 = '295' or MUNICIPALITY2 = '318' or MUNICIPALITY2 = '417' or MUNICIPALITY2 = '438' or MUNICIPALITY2 = '736' or MUNICIPALITY2 = '766' or
MUNICIPALITY2 = '771' or MUNICIPALITY2 = '941' then MAAKUNTA = 21;

 keep MUNICIPALITY2 ID MAAKUNTA;

run;

* Saves data;

data lib100.demografiset_skunta_050624;
 set demografiset_syn;

run;

