<?xml version='1.0' encoding='UTF-8'?>
<codeBook version="1.2.2" ID="MWI-MEIRU-SPOUSELINKS-2002-v01" xml-lang="en" xmlns="http://www.icpsr.umich.edu/DDI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.icpsr.umich.edu/DDI http://www.icpsr.umich.edu/DDI/Version1-2-2.xsd">
  <docDscr>
    <citation>
      <titlStmt>
        <titl>
          marital_spouselinks
        </titl>
        <IDNo>
          DDI-MWI-MEIRU-SPOUSELINKS-2002-v01
        </IDNo>
      </titlStmt>
      <prodStmt>
        <producer abbr="MEIRU" role="Agency">
          Malawi Epidemiology and Intervention Research Unit
        </producer>
        <producer abbr="EM" affiliation="LSHTM and MEIRU" role="Production of the documentation used to create this DDI document.">
          Estelle McLean
        </producer>
        <producer abbr="CK" affiliation="MEIRU" role="Data documentalist">
          Chifundo Kanjala
        </producer>
        <producer abbr="JS" affiliation="LSHTM and MEIRU" role="Production of Data dictionaries">
          Jacky Saul
        </producer>
        <producer abbr="KB" affiliation="LSHTM and MEIRU" role="Production of Data dictionaries">
          Kieth Branson
        </producer>
        <producer abbr="JK" affiliation="MEIRU" role="Metadata entry ">
          Joseph Kamanga
        </producer>
        <producer abbr="DN" affiliation="MEIRU" role="Metadata entry and editing">
          Dominic Nzundah
        </producer>
        <prodDate date="2020-07-23">
          2020-07-23
        </prodDate>
        <software version="4.0.10" date="2018-05-02">
          Nesstar Publisher
        </software>
      </prodStmt>
      <verStmt>
        <version>
          version 1 (July, 2020)
        </version>
      </verStmt>
    </citation>
  </docDscr>
  <stdyDscr>
    <citation>
      <titlStmt>
        <titl>
          Cleaned spouse and marriage data
        </titl>
        <IDNo>
          MWI-MEIRU-SPOUSELINKS-2002-v01
        </IDNo>
      </titlStmt>
      <rspStmt>
        <AuthEnty affiliation="MEIRU, London School of Hygiene and Tropical Medicine (LSHTM)">
          Professor Amelia (Mia) Crampin
        </AuthEnty>
      </rspStmt>
      <prodStmt>
        <software version="4.0.10" date="2018-05-02">
          Nesstar Publisher
        </software>
      </prodStmt>
      <serStmt>
        <serName>
          Sample Survey
        </serName>
      </serStmt>
      <verStmt>
        <version date="2020-07-23">
          <![CDATA[v1:  Edited data, first version, for internal use only]]>
        </version>
      </verStmt>
    </citation>
    <stdyInfo>
      <abstract>
        <![CDATA[The do-file marital_spouselinks.do combines all data on people's marital statuses and reported spouses to create the following datasets:
1. all_marital_reports - a listing of all the times an individual has reported their current marital status with the id numbers of the reported spouse(s); this listing is as reported so may include discrepancies (i.e. a 'Never married' status following a 'Married' one)
2. all_spouse_pairs_full - a listing of each time each spouse pair has been reported plus summary information on co-residency for each pair
3. all_spouse_pairs_clean_summarised - this summarises the data from all_spouse_pairs_full to give start and end dates of unions
4. marital_status_episodes - this combines data from all the sources to create episodes of marital status, each has a start and end date and a marital status, and if currently married, the spouse ids of the current spouse(s) if reported. There are several variables to indicate where each piece of information is coming from.

The first 2 datasets are made available in case people need the 'raw' data for any reason (i.e. if they only want data from one study) or if they wish to summarise the data in a different way to what is done for the last 2 datasets.

The do-file is quite complicated with many sources of data going through multiple processes to create variables in the datasets so it is not always straightforward to explain where each variable come from on the documentation. The 4 datasets build on each other and the do-file is documented throughout so anyone wanting to understand in great detail may be better off examining that. However, below is a brief description of how the datasets are created:

Marital status data are stored in the tables of the study they were collected in:
AHS Adult Health Study [ahs_ahs1]
CEN Census (initial CRS census) [cen_individ]
CENM In-migration (CRS migration form) [crs_cenm]
GP General form (filled for various reasons) [gp_gpform]
SEI Socio-economic individual (annual survey from 2007 onwards) [css_sei]
TBH TB household (study of household contacts of TB patients) [tb_tbh]
TBO TB controls (matched controls for TB patients) [tb_tbo & tb_tboto2007]
TBX TB cases (TB patients) [tb_tbx & tb_tbxto2007]
In many of the above surveys as well as their current marital status, people were asked to report their current and past spouses along with (sometimes) some information about the marriage (start/end year etc.). These data are stored all together on the table gen_spouse, with variables indicating which study the data came from.
Further evidence of spousal relationships is taken from gen_identity (if a couple appear as co-parents to a CRS member) and from crs_residency_episodes_clean_poly, a combined dataset (if they are living in the same household at the same time). Note that co-parent couples who are not reported in gen_spouse are only retained in the datasets if they have co-resident episodes.

The marital status data are appended together and the spouse id data merged in. Minimal data editing/cleaning is carried out. As the spouse data are in long format, this dataset is reshaped wide to have one line per marital status report (polygamy in the area allows for men to have multiple spouses at one time): this dataset is saved as all_marital_reports.

The list of reported spouses on gen_spouse is appended to a list of co-parents (from gen_identity) and this list is cleaned to try to identify and remove obvious id errors (incestuous links, same sex [these are not reported in this culture] and large age difference). Data reported by men and women are compared and variables created to show whether one or both of the couple report the union.
Many records have information on start and end year of marriage, and all have the date the union was reported. This listing is compared to data from residency episodes to add dates that couples were living together (not all have start/end dates so this is to try to supplement this), in addition the dates that each member of the couple was last known to be alive or first known to be dead are added (from the residency data as well). This dataset with all the records available for each spouse pair is saved as all_spouse_pairs_full.

The date data from all_spouse_pairs_full are then summarised to get one line per couple with earliest and latest known married date for all, and, if available, marriage and separation date. For each date there are also variables created to indicate the source of the data.	
As culture only allows for women having one spouse at a time, records for women with 'overlapping' husbands are cleaned. This dataset is then saved as all_spouse_pairs_clean_summarised.	

Both the cleaned spouse pairs and the cleaned marital status datasets are converted into episodes: the spouse listing using the marriage or first known married date as the beginning and the last known married plus a year or separation date as the end, the marital status data records collapsed into periods of the same status being reported (following some cleaning to remove impossible reports) and the start date being the first of these reports, the end date being the last of the reports plus a year. These episodes are appended together and a series of processes run several times to remove overalapping episodes. To be able to assign specific spouse ids to each married episode, some episodes need to be 'split' into more than one (i.e. if a man is married to one woman from 2005 to 2017 and then marries another woman in 2008 and remains married to her till 2017 his intial married episode would be from 2005 to 2017, but this would need to be split into one from 2005 to 2008 which would just have 1 idspouse attached and another from 2008 to 2017, which would have 2 idspouse attached). After this splitting process the spouse ids are merged in.	
The final episode dataset is saved as marital_status_episodes.]]>
      </abstract>
      <sumDscr>
        <nation abbr="MWI">
          Malawi
        </nation>
        <anlyUnit>
          Individual
        </anlyUnit>
      </sumDscr>
    </stdyInfo>
    <method>
      <dataColl>
        <dataCollector abbr="MEIRU">
          Malawi Epidemiology and Intervention Research Unit
        </dataCollector>
        <collMode>
          Face-to-face [f2f]
        </collMode>
        <sources/>
      </dataColl>
    </method>
    <dataAccs>
      <setAvail>
        <origArch>
          MEIRU
        </origArch>
      </setAvail>
      <useStmt>
        <contact>
          Malawi Epidemiology and Intervention Research Unit
        </contact>
        <conditions>
          <![CDATA[This data is made available for licensed access under the following conditions:

1. Data and other material provided by MEIRU will not be redistributed or sold to other individuals, institutions or organisations without MEIRU's written agreement.

2. In the case of multi-centre datasets, data originating from a single contributing member centre of the collaboration may not be analysed or reported on in isolation without the express permission of the member centre concerned.

3. No attempt will be made to re-identify respondents, and there will be no use of the identity of any person or establishment discovered inadvertently. Any such discovery will be reported immediately to MEIRU.

4. No attempt will be made to produce links between datasets provided by MEIRU or between MEIRU data and other datasets that could identify individuals.

5. Any books, articles, conference papers, theses, dissertations, reports or other publications employing data obtained from MEIRU will cite the source, in line with the citation requirement provided with the dataset.

6. An electronic copy of all publications based on the requested data will be sent to MEIRU.

7. MEIRU, MEIRU research collaborators and the relevant funding agencies bear no responsibility for the data's use or interpretation or inferences based upon it.]]>
        </conditions>
      </useStmt>
    </dataAccs>
  </stdyDscr>
  <fileDscr ID="F2" URI="marital_spouselinks.Nesstar?Index=0&amp;Name=all_marital_reports">
    <fileTxt>
      <fileName>
        all_marital_reports.NSDstat
      </fileName>
      <fileCont>
        <![CDATA[This is a listing of all the times an individual has reported their current marital status with the id numbers of the reported spouse(s); this listing is as reported so may include discrepancies (i.e. a 'Never married' status following a 'Married' one)	
In the variable labels (S) indicates that the variable is unchanged from the original source and (D) indicates that it is a 'derived' variable, often using more than one source variable. For both types information on where the data come from and how they are processed is found in the 'Recoding and Derivation' section]]>
      </fileCont>
      <dimensns>
        <caseQnty>
          263339
        </caseQnty>
        <varQnty>
          16
        </varQnty>
      </dimensns>
      <fileType>
        Nesstar 200801
      </fileType>
      <filePlac>
        Malawi Epidemiology and Interventions Research Unit
      </filePlac>
    </fileTxt>
  </fileDscr>
  <fileDscr ID="F4" URI="marital_spouselinks.Nesstar?Index=1&amp;Name=all_spouse_pairs_full">
    <fileTxt>
      <fileName>
        all_spouse_pairs_full.NSDstat
      </fileName>
      <fileCont>
        <![CDATA[This a listing of each time each spouse pair has been reported plus summary information on co-residency for each pair	
In the variable labels (S) indicates that the variable is unchanged from the original source and (D) indicates that it is a 'derived' variable, often using more than one source variable. For both types information on where the data come from and how they are processed is found in the 'Recoding and Derivation' section]]>
      </fileCont>
      <dimensns>
        <caseQnty>
          196403
        </caseQnty>
        <varQnty>
          33
        </varQnty>
      </dimensns>
      <fileType>
        Nesstar 200801
      </fileType>
      <filePlac>
        Malawi Epidemiology and Interventions Research Unit
      </filePlac>
    </fileTxt>
  </fileDscr>
  <fileDscr ID="F3" URI="marital_spouselinks.Nesstar?Index=2&amp;Name=all_spouse_pairs_clean_summarised">
    <fileTxt>
      <fileName>
        all_spouse_pairs_clean_summarised.NSDstat
      </fileName>
      <fileCont>
        <![CDATA[This summarises the data from all_spouse_pairs_full to give start and end dates of unions	
In the variable labels (S) indicates that the variable is unchanged from the original source and (D) indicates that it is a 'derived' variable, often using more than one source variable. For both types information on where the data come from and how they are processed is found in the 'Recoding and Derivation' section]]>
      </fileCont>
      <dimensns>
        <caseQnty>
          22800
        </caseQnty>
        <varQnty>
          32
        </varQnty>
      </dimensns>
      <fileType>
        Nesstar 200801
      </fileType>
      <filePlac>
        Malawi Epidemiology and Interventions Research Unit
      </filePlac>
    </fileTxt>
  </fileDscr>
  <fileDscr ID="F5" URI="marital_spouselinks.Nesstar?Index=3&amp;Name=marital_status_episodes">
    <fileTxt>
      <fileName>
        marital_status_episodes.NSDstat
      </fileName>
      <fileCont>
        <![CDATA[This combines data from all the sources to create episodes of marital status, each has a start and end date and a marital status, and if currently married, the spouse ids of the current spouse(s) if reported. There are several variables to indicate where each piece of information is coming from.	
In the variable labels (S) indicates that the variable is unchanged from the original source and (D) indicates that it is a 'derived' variable, often using more than one source variable. For both types information on where the data come from and how they are processed is found in the 'Recoding and Derivation' section]]>
      </fileCont>
      <dimensns>
        <caseQnty>
          134177
        </caseQnty>
        <varQnty>
          32
        </varQnty>
      </dimensns>
      <fileType>
        Nesstar 200801
      </fileType>
      <filePlac>
        Malawi Epidemiology and Interventions Research Unit
      </filePlac>
    </fileTxt>
  </fileDscr>
  <dataDscr>
    <var ID="V1" name="ident" files="F2" intrvl="discrete">
      <location StartPos="1" EndPos="7" width="7" RecSegNo="1"/>
      <labl>
        Unique identifier
      </labl>
      <sumStat type="vald">
        263339
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Unique identifier
      </txt>
      <codInstr>
        variable: ident (table[s]: ahs_ahs1, cen_individ, crs_cenm, gp_gpform, css_sei, tb_tbh, tb_tbo, tb_tboto2007, tb_tbx, tb_tbxto2007)
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V2" name="intdate" files="F2" intrvl="discrete">
      <location StartPos="8" EndPos="17" width="10" RecSegNo="1"/>
      <labl>
        Date of interview
      </labl>
      <sumStat type="vald">
        263339
      </sumStat>
      <txt>
        Date of interview
      </txt>
      <codInstr>
        variable: intdate (table[s]: ahs_ahs1, cen_individ, crs_cenm, gp_gpform, css_sei, tb_tbh, tb_tbo, tb_tboto2007, tb_tbx, tb_tbxto2007)
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V3" name="ques" files="F2" intrvl="discrete">
      <location StartPos="18" EndPos="20" width="3" RecSegNo="1"/>
      <labl>
        Source of data (D)
      </labl>
      <sumStat type="vald">
        263339
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Source of data
      </txt>
      <codInstr>
        <![CDATA[Created when each data source is appended together, e.g.:
use ident intdate marital using ${newstata}\ahs_ahs1, clear
gen ques="AHS"
gen slf=1
append using ${newstata}\cen_individ, keep(ident intdate marital spoucur spoupast self informtid)
replace ques="CEN" if ques==""
etc.]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V4" name="poprep" files="F2" dcml="0" intrvl="discrete">
      <location StartPos="21" EndPos="21" width="1" RecSegNo="1"/>
      <labl>
        <![CDATA[From population representative survey
From population representative survey
]]>
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        263339
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        From population representative survey
      </txt>
      <codInstr>
        <![CDATA[variable: ques (table[s]: this dataset)

gen poprep=ques=="AHS" | ques=="CEN" | ques=="CNM" | ques=="SEI"]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V5" name="slf" files="F2" dcml="0" intrvl="discrete">
      <location StartPos="22" EndPos="23" width="2" RecSegNo="1"/>
      <labl>
        Self or proxy report (D)
      </labl>
      <valrng>
        <range min="-1" max="1"/>
      </valrng>
      <sumStat type="vald">
        263195
      </sumStat>
      <sumStat type="invd">
        144
      </sumStat>
      <txt>
        Self or proxy report
      </txt>
      <catgry>
        <catValu>
          -1
        </catValu>
        <labl>
          Unknown
        </labl>
        <catStat type="freq">
          1165
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          Proxy-report
        </labl>
        <catStat type="freq">
          210895
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Self-report
        </labl>
        <catStat type="freq">
          51135
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          144
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: self (table[s]: cen_individ, crs_cenm, gp_gpform, tb_tbh, tb_tbo, tb_tboto2007, tb_tbx, tb_tbxto2007)
variable: infmtype (table[s]: crs_cenm)
variable: infmtype2 (table[s]: crs_cenm)
variable: relinform (table[s]: tb_tbx)
variable: informtid (table[s]: gp_gpform)

<for AHS (no proxies):>
gen slf=1
<for CEN:>
recode slf .=-1
replace slf=0 if self==0 | informtid~=""
replace slf=1 if self==1
<for CENM:>
recode slf .=-1
replace slf=0 if self==0 | (infmtype~=. & infmtype~=6) //6=self
replace slf=1 if self==1 | infmtype==6
<for GP:>
recode slf .=-1
replace slf=0 if self==0 | informtid~=""
replace slf=1 if self==1
<for SEI:>
recode slf .=-1
replace slf=0 if infmtype2~=1 & infmtype2~=99 & infmtype~=6
replace slf=1 if infmtype2==1 | infmtype==6
<for TBH:>
recode slf .=-1
replace slf=0 if self==0
replace slf=1 if self==1
<for TBO:>
recode slf .=-1
replace slf=0 if self==0
replace slf=1 if self==1
<for TBX:>
recode slf .=-1
replace slf=0 if (relinform~=8 & relinform~=.) | informtid~=""
replace slf=1 if relinform==8]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V6" name="marital" files="F2" dcml="0" intrvl="discrete">
      <location StartPos="24" EndPos="24" width="1" RecSegNo="1"/>
      <labl>
        Marital status (D)
      </labl>
      <valrng>
        <range min="0" max="9"/>
      </valrng>
      <invalrng>
        <item VALUE="9"/>
      </invalrng>
      <sumStat type="vald">
        259912
      </sumStat>
      <sumStat type="invd">
        3427
      </sumStat>
      <txt>
        Marital status
      </txt>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          Never married
        </labl>
        <catStat type="freq">
          84882
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Married
        </labl>
        <catStat type="freq">
          141125
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Divorced/separated
        </labl>
        <catStat type="freq">
          18136
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Widowed
        </labl>
        <catStat type="freq">
          15769
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          N/A (dead)
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          8
        </catValu>
        <labl>
          Unknown
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          9
        </catValu>
        <labl>
          Missing
        </labl>
        <catStat type="freq">
          3414
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          13
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: marital (table[s]: ahs_ahs1, cen_individ, crs_cenm, gp_gpform, css_sei, tb_tbh, tb_tbo, tb_tboto2007, tb_tbx, tb_tbxto2007)
variable: spoucur (table[s]: cen_individ, crs_cenm)
variable: spoupast (table[s]: cen_individ, crs_cenm)
variable: maridill (table[s]: tb_tbxto2007) 
variable: idspouse (table[s]: gen_spouse)
variable: marendyr (table[s]: gen_spouse) 

Mostly the variables is used as reported but for a few sources it is updated using other data:
la def marital 4 "N/A (dead)", modify
replace marital=0 if spoucur==0 & spoupast<=0 & marital==.
replace marital=1 if spoucur>=1 & spoucur~=. & marital==.
replace marital=2 if spoucur==0 & spoupast>=1 & spoupast~=. & marital==.
replace marital=0 if maridill==0 /*just assumed that not married is never married for these ones for now*/
replace marital=1 if maridill==1
<and after merging in reported spouse ids from gen_spouse:>
replace marital=1 if idspouse~="" & marendyr==.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V7" name="spousenum" files="F2" dcml="0" intrvl="discrete">
      <location StartPos="25" EndPos="26" width="2" RecSegNo="1"/>
      <labl>
        Number of current spouses (D)
      </labl>
      <valrng>
        <range min="0" max="99"/>
      </valrng>
      <sumStat type="vald">
        112388
      </sumStat>
      <sumStat type="invd">
        150951
      </sumStat>
      <txt>
        Number of current spouses
      </txt>
      <catgry>
        <catValu>
          97
        </catValu>
        <labl>
          Not applicable
        </labl>
      </catgry>
      <catgry>
        <catValu>
          98
        </catValu>
        <labl>
          Unknown
        </labl>
      </catgry>
      <catgry>
        <catValu>
          99
        </catValu>
        <labl>
          Missing
        </labl>
      </catgry>
      <codInstr>
        <![CDATA[variable: spousenum (table[s]: css_sei)
variable: spoucur (table[s]: cen_individ, crs_cenm)

replace spousenum=spoucur if spousenum==.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V8" name="idspouse1" files="F2" intrvl="discrete">
      <location StartPos="27" EndPos="33" width="7" RecSegNo="1"/>
      <labl>
        Spouse id (1)
      </labl>
      <sumStat type="vald">
        138401
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Spouse id
      </txt>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: gen_spouse)

This is mostly the spouse id variable as recorded reshaped wide by interview (so it repeats, idspouse1, idspouse2 etc.), but the code 'noid' is added when a spouse is reported but id not recorded.
replace idspouse="noid" if _m~=1 & idspouse==""
replace idspouse="" if idspouse~="noid" | marital~=1
bys ident intdate idspouse: gen n=_n
tostring n, replace
replace idspouse=idspouse+n if idspouse=="noid"
bys ident intdate (idspouse): gen n=_n
reshape wide idspouse, i(ident intdate) j(n)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V9" name="idspouse2" files="F2" intrvl="discrete">
      <location StartPos="34" EndPos="40" width="7" RecSegNo="1"/>
      <labl>
        Spouse id (2)
      </labl>
      <sumStat type="vald">
        11388
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Spouse id
      </txt>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: gen_spouse)

This is mostly the spouse id variable as recorded reshaped wide by interview (so it repeats, idspouse1, idspouse2 etc.), but the code 'noid' is added when a spouse is reported but id not recorded.
replace idspouse="noid" if _m~=1 & idspouse==""
replace idspouse="" if idspouse~="noid" | marital~=1
bys ident intdate idspouse: gen n=_n
tostring n, replace
replace idspouse=idspouse+n if idspouse=="noid"
bys ident intdate (idspouse): gen n=_n
reshape wide idspouse, i(ident intdate) j(n)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V10" name="idspouse3" files="F2" intrvl="discrete">
      <location StartPos="41" EndPos="47" width="7" RecSegNo="1"/>
      <labl>
        Spouse id (3)
      </labl>
      <sumStat type="vald">
        1827
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Spouse id
      </txt>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: gen_spouse)

This is mostly the spouse id variable as recorded reshaped wide by interview (so it repeats, idspouse1, idspouse2 etc.), but the code 'noid' is added when a spouse is reported but id not recorded.
replace idspouse="noid" if _m~=1 & idspouse==""
replace idspouse="" if idspouse~="noid" | marital~=1
bys ident intdate idspouse: gen n=_n
tostring n, replace
replace idspouse=idspouse+n if idspouse=="noid"
bys ident intdate (idspouse): gen n=_n
reshape wide idspouse, i(ident intdate) j(n)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V11" name="idspouse4" files="F2" intrvl="discrete">
      <location StartPos="48" EndPos="54" width="7" RecSegNo="1"/>
      <labl>
        Spouse id (4)
      </labl>
      <sumStat type="vald">
        382
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Spouse id
      </txt>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: gen_spouse)

This is mostly the spouse id variable as recorded reshaped wide by interview (so it repeats, idspouse1, idspouse2 etc.), but the code 'noid' is added when a spouse is reported but id not recorded.
replace idspouse="noid" if _m~=1 & idspouse==""
replace idspouse="" if idspouse~="noid" | marital~=1
bys ident intdate idspouse: gen n=_n
tostring n, replace
replace idspouse=idspouse+n if idspouse=="noid"
bys ident intdate (idspouse): gen n=_n
reshape wide idspouse, i(ident intdate) j(n)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V12" name="idspouse5" files="F2" intrvl="discrete">
      <location StartPos="55" EndPos="61" width="7" RecSegNo="1"/>
      <labl>
        Spouse id (5)
      </labl>
      <sumStat type="vald">
        26
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Spouse id
      </txt>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: gen_spouse)

This is mostly the spouse id variable as recorded reshaped wide by interview (so it repeats, idspouse1, idspouse2 etc.), but the code 'noid' is added when a spouse is reported but id not recorded.
replace idspouse="noid" if _m~=1 & idspouse==""
replace idspouse="" if idspouse~="noid" | marital~=1
bys ident intdate idspouse: gen n=_n
tostring n, replace
replace idspouse=idspouse+n if idspouse=="noid"
bys ident intdate (idspouse): gen n=_n
reshape wide idspouse, i(ident intdate) j(n)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V13" name="idspouse6" files="F2" intrvl="discrete">
      <location StartPos="62" EndPos="66" width="5" RecSegNo="1"/>
      <labl>
        Spouse id (6)
      </labl>
      <sumStat type="vald">
        8
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Spouse id
      </txt>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: gen_spouse)

This is mostly the spouse id variable as recorded reshaped wide by interview (so it repeats, idspouse1, idspouse2 etc.), but the code 'noid' is added when a spouse is reported but id not recorded.
replace idspouse="noid" if _m~=1 & idspouse==""
replace idspouse="" if idspouse~="noid" | marital~=1
bys ident intdate idspouse: gen n=_n
tostring n, replace
replace idspouse=idspouse+n if idspouse=="noid"
bys ident intdate (idspouse): gen n=_n
reshape wide idspouse, i(ident intdate) j(n)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V14" name="idspouse7" files="F2" intrvl="discrete">
      <location StartPos="67" EndPos="71" width="5" RecSegNo="1"/>
      <labl>
        Spouse id (7)
      </labl>
      <sumStat type="vald">
        6
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Spouse id
      </txt>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: gen_spouse)

This is mostly the spouse id variable as recorded reshaped wide by interview (so it repeats, idspouse1, idspouse2 etc.), but the code 'noid' is added when a spouse is reported but id not recorded.
replace idspouse="noid" if _m~=1 & idspouse==""
replace idspouse="" if idspouse~="noid" | marital~=1
bys ident intdate idspouse: gen n=_n
tostring n, replace
replace idspouse=idspouse+n if idspouse=="noid"
bys ident intdate (idspouse): gen n=_n
reshape wide idspouse, i(ident intdate) j(n)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V15" name="idspouse8" files="F2" intrvl="discrete">
      <location StartPos="72" EndPos="76" width="5" RecSegNo="1"/>
      <labl>
        Spouse id (8)
      </labl>
      <sumStat type="vald">
        2
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Spouse id
      </txt>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: gen_spouse)

This is mostly the spouse id variable as recorded reshaped wide by interview (so it repeats, idspouse1, idspouse2 etc.), but the code 'noid' is added when a spouse is reported but id not recorded.
replace idspouse="noid" if _m~=1 & idspouse==""
replace idspouse="" if idspouse~="noid" | marital~=1
bys ident intdate idspouse: gen n=_n
tostring n, replace
replace idspouse=idspouse+n if idspouse=="noid"
bys ident intdate (idspouse): gen n=_n
reshape wide idspouse, i(ident intdate) j(n)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V16" name="idspouse9" files="F2" intrvl="discrete">
      <location StartPos="77" EndPos="81" width="5" RecSegNo="1"/>
      <labl>
        Spouse id (9)
      </labl>
      <sumStat type="vald">
        1
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Spouse id
      </txt>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: gen_spouse)

This is mostly the spouse id variable as recorded reshaped wide by interview (so it repeats, idspouse1, idspouse2 etc.), but the code 'noid' is added when a spouse is reported but id not recorded.
replace idspouse="noid" if _m~=1 & idspouse==""
replace idspouse="" if idspouse~="noid" | marital~=1
bys ident intdate idspouse: gen n=_n
tostring n, replace
replace idspouse=idspouse+n if idspouse=="noid"
bys ident intdate (idspouse): gen n=_n
reshape wide idspouse, i(ident intdate) j(n)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V49" name="wife" files="F4" intrvl="discrete">
      <location StartPos="1" EndPos="7" width="7" RecSegNo="1"/>
      <labl>
        Unique identifier of wife (D)
      </labl>
      <sumStat type="vald">
        196403
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Unique identifier of wife
      </txt>
      <codInstr>
        <![CDATA[variable: ident (table[s]: gen_spouse, crs_residency_episodes_clean_poly [derived table], all_marital_reports [derived table])
variable: idspouse (table[s]: gen_spouse)
variable: idmoth (table[s]: gen_identity)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V50" name="husband" files="F4" intrvl="discrete">
      <location StartPos="8" EndPos="14" width="7" RecSegNo="1"/>
      <labl>
        Unique identifier of husband (D)
      </labl>
      <sumStat type="vald">
        196403
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        <![CDATA[
Unique identifier of husband]]>
      </txt>
      <codInstr>
        <![CDATA[variable: ident (table[s]: gen_spouse, crs_residency_episodes_clean_poly [derived table], all_marital_reports [derived table])
variable: idspouse (table[s]: gen_spouse)
variable: idfath (table[s]: gen_identity)]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V51" name="datatype" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="15" EndPos="15" width="1" RecSegNo="1"/>
      <labl>
        Type of data (D)
      </labl>
      <valrng>
        <range min="1" max="2"/>
      </valrng>
      <sumStat type="vald">
        196403
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Type of data
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          marstatus
        </labl>
        <catStat type="freq">
          158094
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          residency
        </labl>
        <catStat type="freq">
          38309
        </catStat>
      </catgry>
      <codInstr>
        Created when making the separate datasets and appending them together.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V52" name="sumdate" files="F4" intrvl="discrete">
      <location StartPos="16" EndPos="25" width="10" RecSegNo="1"/>
      <labl>
        Summary date for record (D)
      </labl>
      <sumStat type="vald">
        196403
      </sumStat>
      <txt>
        <![CDATA[	
Summary date for record to make it easier to sort/understand data]]>
      </txt>
      <codInstr>
        <![CDATA[variable: date (table[s]: this dataset)
variable: rmardate (table[s]: this dataset)
variable: rsepdate (table[s]: this dataset)

egen sumdate=rowmin(date rmardate rsepdate)]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V53" name="repby" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="26" EndPos="26" width="1" RecSegNo="1"/>
      <labl>
        Union ever reported by (D)
      </labl>
      <valrng>
        <range min="1" max="3"/>
      </valrng>
      <sumStat type="vald">
        193050
      </sumStat>
      <sumStat type="invd">
        3353
      </sumStat>
      <txt>
        Union ever reported by
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          12540
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          2958
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          177552
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          3353
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: ident (table[s]: gen_spouse)
variable: idspouse (table[s]: gen_spouse)

The data from gen_spouse is split into male and female reports which are merged into each other, the resulting merge variable is used to create repby. NB. the spouse_match_ datasets referred to below are the separated datasets:
use ident idspouse using ${tempfiles}\spouse_match_1, clear
rename (ident idspouse) (wife husband)
duplicates drop
save ${tempfiles}\couples_Freport, replace
use ident idspouse using ${tempfiles}\spouse_match_0, clear
rename (ident idspouse) (husband wife)
duplicates drop
merge 1:1 wife husband using ${tempfiles}\couples_Freport
gen repby=3 if _m==3 /*if they match they have both reported each other at least once*/
replace repby=1 if _m==2 /*if the union is only in the using data then only the wife has ever reported it*/
replace repby=2 if _m==1 /*if the union is only in the master data then only the husband has ever reported it*/
la val repby repby
drop _m
save ${tempfiles}\spouses_ever_reported, replace]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V54" name="confirmed" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="27" EndPos="27" width="1" RecSegNo="1"/>
      <labl>
        Both partners report the union at least once (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        193050
      </sumStat>
      <sumStat type="invd">
        3353
      </sumStat>
      <txt>
        <![CDATA[
Both partners report the union at least once]]>
      </txt>
      <codInstr>
        <![CDATA[variable: repby (table[s]: this dataset)

gen confirmed=0
replace confirmed=1 if repby==3]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V55" name="agediff" files="F4" dcml="0" intrvl="contin">
      <location StartPos="28" EndPos="29" width="2" RecSegNo="1"/>
      <labl>
        Age difference between spouses (D)
      </labl>
      <valrng>
        <range min="0" max="69"/>
      </valrng>
      <sumStat type="vald">
        196385
      </sumStat>
      <sumStat type="invd">
        18
      </sumStat>
      <txt>
        <![CDATA[
Age difference between spouses]]>
      </txt>
      <codInstr>
        <![CDATA[variable: ident (table[s]: gen_spouse)
variable: idspouse (table[s]: gen_spouse)
variable: birth_date (table[s]: gen_identity_clean [derived table])

rename (ident idspouse) (ident1 ident)
merge m:1 ident using ${newstata}\gen_identity_clean.dta, keepusing(sex birth_date idmoth idfath) keep(master match) nogen
gen idspouse_age=int((intdate-birth_date)/365.25) if birth_date~=.
gen idspouse_yob=year(birth_date) if birth_date~=.
drop birth_date
rename (ident1 ident sex idmoth idfath) (ident idspouse idspouse_sex idspouse_idmoth idspouse_idfath)
gen agediff=abs(ident_age-idspouse_age)]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V56" name="samesex" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="30" EndPos="30" width="1" RecSegNo="1"/>
      <labl>
        Union has same sex error (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        196403
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        <![CDATA[
Union has same sex error]]>
      </txt>
      <codInstr>
        <![CDATA[variable: sex (table[s]: gen_identity)

gen samesex=0
replace samesex=1 if ident_sex==idspouse_sex]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V57" name="everU12" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="31" EndPos="31" width="1" RecSegNo="1"/>
      <labl>
        Union has under 12 years error (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        196403
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Union has under 12 years error
      </txt>
      <codInstr>
        <![CDATA[bys ident idspouse: egen youngestident=min(ident_age)
bys ident idspouse: egen youngestidspouse=min(idspouse_age)
gen everU12=0
replace everU12=1 if (youngestident<12 & youngestident~=.) | (youngestidspouse<12 & youngestidspouse~=.)]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V58" name="incest" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="32" EndPos="32" width="1" RecSegNo="1"/>
      <labl>
        Union has incest error (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        196403
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        <![CDATA[	
Union has incest error]]>
      </txt>
      <codInstr>
        <![CDATA[variable: ident (table[s]: gen_spouse)
variable: idspouse (table[s]: gen_spouse)
variable: idmoth (table[s]: gen_identity)
variable: idfath (table[s]: gen_identity)

gen incest=0
replace incest=1 if (ident_idmoth==idspouse & ident_idmoth~="" & idspouse~="") | (ident_idfath==idspouse & ident_idfath~="" & idspouse~="")  |			          (idspouse_idmoth==ident & idspouse_idmoth~="" & ident~="") | (idspouse_idfath==ident & idspouse_idfath~="" & ident~="")]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V59" name="crs" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="33" EndPos="33" width="1" RecSegNo="1"/>
      <labl>
        Partners ever CRS members (D)
      </labl>
      <valrng>
        <range min="1" max="3"/>
      </valrng>
      <sumStat type="vald">
        188811
      </sumStat>
      <sumStat type="invd">
        7592
      </sumStat>
      <txt>
        <![CDATA[	
Partners ever CRS members]]>
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          7473
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          774
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          180564
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          7592
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[<A listing of all idents that were ever CRS members is created:>
use ${gendata}\crs_residency_episodes_clean_nopoly, clear
bys ident: egen lastincrs=max(stopdate)
bys ident (stopdate): gen laststop=stoptype[_N]
format %td lastincrs
keep ident lastincrs laststop
duplicates drop
gen crs=1
save ${tempfiles}\allcrsmembers, replace
<then this is merged into the main dataset for each partner:>
merge m:1 ident using ${tempfiles}\allcrsmembers, keep(master match) keepusing(crs) nogen
merge m:1 ident using ${tempfiles}\indices_lafd, keep(master match) nogen
rename (ident husband lastalive firstdead crs) (wife ident w_lastalive w_firstdead w_crs)
merge m:1 ident using ${tempfiles}\allcrsmembers, keep(master match) keepusing(crs) nogen
merge m:1 ident using ${tempfiles}\indices_lafd, keep(master match) nogen
rename (ident lastalive firstdead crs) (husband h_lastalive h_firstdead h_crs)
gen crs=1 if w_crs==1 & h_crs~=1
replace crs=2 if w_crs~=1 & h_crs==1
replace crs=3 if w_crs==1 & h_crs==1
la val crs repby]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V60" name="newparlink" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="34" EndPos="34" width="1" RecSegNo="1"/>
      <labl>
        Partnership only from co-parent link (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        196403
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Partnership only from co-parent link
      </txt>
      <codInstr>
        <![CDATA[<The variable parlink is created when co-parent data is processed before being appended to other spouse data:>
use ${newstata}\gen_identity_clean, clear
replace idmoth="" if idmoth=="UUUUUUU"
replace idfath="" if idfath=="UUUUUUU"
keep if idmoth~="" & idfath~=""
rename (idmoth idfath) (ident idspouse)
gen parlink=1
<After all data are combined parlink is used to id couples who remain in the dataset as they have lived together but have never reported each other as spouses:>
recode parlink .=0
bys wife husband: egen newparlink=min(parlink)]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V61" name="ques" files="F4" intrvl="discrete">
      <location StartPos="35" EndPos="37" width="3" RecSegNo="1"/>
      <labl>
        Source of marstatus record (D)
      </labl>
      <sumStat type="vald">
        158094
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        <![CDATA[	
Source of marstatus record]]>
      </txt>
      <codInstr>
        variable: ques (table[s]: all_marital_reports [derived table])
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V62" name="poprep" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="38" EndPos="38" width="1" RecSegNo="1"/>
      <labl>
        Source is population representative (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        193050
      </sumStat>
      <sumStat type="invd">
        3353
      </sumStat>
      <txt>
        Source is population representative
      </txt>
      <codInstr>
        variable: poprep (table[s]: all_marital_reports [derived table])
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V63" name="date" files="F4" intrvl="discrete">
      <location StartPos="39" EndPos="48" width="10" RecSegNo="1"/>
      <labl>
        Interview date of marstatus record (D)
      </labl>
      <sumStat type="vald">
        158094
      </sumStat>
      <txt>
        <![CDATA[	
Interview date of marstatus record]]>
      </txt>
      <codInstr>
        variable: date (table[s]: all_marital_reports [derived table])
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V64" name="informant" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="49" EndPos="49" width="1" RecSegNo="1"/>
      <labl>
        Informant of marstatus record (D)
      </labl>
      <valrng>
        <range min="1" max="3"/>
      </valrng>
      <sumStat type="vald">
        158094
      </sumStat>
      <sumStat type="invd">
        38309
      </sumStat>
      <txt>
        <![CDATA[
Informant of marstatus record]]>
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          85559
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          72535
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          38309
        </catStat>
      </catgry>
      <codInstr>
        variable: informant (table[s]: all_marital_reports [derived table])
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V65" name="match" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="50" EndPos="50" width="1" RecSegNo="1"/>
      <labl>
        Whether partner reports union in same round (D)
      </labl>
      <valrng>
        <range min="0" max="2"/>
      </valrng>
      <sumStat type="vald">
        158094
      </sumStat>
      <sumStat type="invd">
        38309
      </sumStat>
      <txt>
        <![CDATA[	
Whether partner reports union in same round]]>
      </txt>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          Matched
        </labl>
        <catStat type="freq">
          128948
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Missing data
        </labl>
        <catStat type="freq">
          25335
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Mismatch
        </labl>
        <catStat type="freq">
          3811
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          38309
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: ident (table[s]: gen_spouse)
variable: idspouse (table[s]: gen_spouse)
variable: marital (table[s]: ahs_ahs1, cen_individ, crs_cenm, gp_gpform, css_sei, tb_tbh, tb_tbo, tb_tboto2007, tb_tbx, tb_tbxto2007)
variable: spoucur (table[s]: cen_individ, crs_cenm)
variable: spoupast (table[s]: cen_individ, crs_cenm)
variable: maridill (table[s]: tb_tbxto2007) 
variable: idspouse (table[s]: gen_spouse)
variable: marendyr (table[s]: gen_spouse) 

<Once the marital status report and spouse listing datasets are merged together they are split into what men and women are reporting per round/survey and merged together to assess whether each report is reported by the otehr partner:>
foreach spouse in wife husband {
	preserve
	if "`spouse'"=="wife" {
		local sexi=1
		local sexs=0
		local S="H"
		}
	if "`spouse'"=="husband" {
		local sexi=0
		local sexs=1
		local S="W"
		}
	*create dataset of what the spouse 2 (idspouse) reports
	drop if ident_sex==`sexi'
	rename (idspouse ident marital) (x`spouse' idspouse xmarital)
	keep idspouse x`spouse' rd xmarital
	bys idspouse rd: gen n=_n
	sum n
	local max=r(max)
	reshape wide xmarital x`spouse' ,i(idspouse rd) j(n)
	save ${tempfiles}\gen_spouse_`sexs', replace
	restore 
	preserve
	*create dataset of what spouse 1 (ident) reports and merge with the spouse 2 dataset
	drop if ident_sex==`sexs'
	drop if idspouse=="" | idspouse=="noid"
	merge m:1 idspouse rd using ${tempfiles}\gen_spouse_`sexs', keep(master match) nogen
	*create match var
	gen match=.
	forvalues x=1/`max' {
		replace match=0 if ident==x`spouse'`x'
		}
	replace match=1 if match==. &(xmarital1==. | (xmarital1~=0 & x`spouse'1==""))
	replace match=2 if match==. & x`spouse'1~="" | xmarital1==0
	lab def match 0 "Matched" 1 "Missing data" 2 "Mismatch"
	la val match match
	drop x*
	save ${tempfiles}\spouse_match_`sexi', replace
	restore
	}]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V66" name="heverpolyn" files="F4" dcml="0" intrvl="contin">
      <location StartPos="51" EndPos="52" width="2" RecSegNo="1"/>
      <labl>
        Max number of spouses husband reports while in this union (D)
      </labl>
      <valrng>
        <range min="0" max="99"/>
      </valrng>
      <sumStat type="vald">
        164160
      </sumStat>
      <sumStat type="invd">
        32243
      </sumStat>
      <txt>
        <![CDATA[
Max number of spouses husband reports while in this union]]>
      </txt>
      <codInstr>
        <![CDATA[variable: informant (table[s]: all_marital_reports [derived table])
variable: spousenum (table[s]: all_marital_reports [derived table])

replace spousenum=. if informant==1 //only want husband number of spouses to know if union is polygamous
bys wife husband: egen heverpolyn=max(spousenum)]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V67" name="everpoly" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="53" EndPos="53" width="1" RecSegNo="1"/>
      <labl>
        Union was ever polygamous (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        164160
      </sumStat>
      <sumStat type="invd">
        32243
      </sumStat>
      <txt>
        Union was ever polygamous (D)
      </txt>
      <codInstr>
        <![CDATA[variable: heverpolyn (table[s]: this dataset)

recode heverpolyn 1=0 2/max=1, gen(everpoly)]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V68" name="evercur" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="54" EndPos="54" width="1" RecSegNo="1"/>
      <labl>
        Union ever reported to be current (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        193050
      </sumStat>
      <sumStat type="invd">
        3353
      </sumStat>
      <txt>
        <![CDATA[	
Union ever reported to be current]]>
      </txt>
      <codInstr>
        gen evercur=marital==1
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V69" name="mardate" files="F4" intrvl="discrete">
      <location StartPos="55" EndPos="64" width="10" RecSegNo="1"/>
      <labl>
        Marriage date (15-April of reported year) (D)
      </labl>
      <sumStat type="vald">
        118254
      </sumStat>
      <txt>
        <![CDATA[
Marriage date (15-April of reported year)]]>
      </txt>
      <codInstr>
        gen mardate=mdy(4,15,marstyr) if marstyr~=. &amp; marstyr&lt;9998
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V70" name="stillmardate" files="F4" intrvl="discrete">
      <location StartPos="65" EndPos="74" width="10" RecSegNo="1"/>
      <labl>
        Last date still reported to be married (D)
      </labl>
      <sumStat type="vald">
        139996
      </sumStat>
      <txt>
        <![CDATA[
Last date still reported to be married]]>
      </txt>
      <codInstr>
        gen stillmardate=intdate if wife~="" &amp; husband~="" &amp; marendyr==.
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V71" name="sepdate" files="F4" intrvl="discrete">
      <location StartPos="75" EndPos="84" width="10" RecSegNo="1"/>
      <labl>
        Separation date (15-Aug of reported year) (D)
      </labl>
      <sumStat type="vald">
        15846
      </sumStat>
      <txt>
        <![CDATA[
Separation date (15-Aug of reported year)]]>
      </txt>
      <codInstr>
        gen sepdate=mdy(8,15,marendyr) if marendyr~=. &amp; marendyr&lt;9998
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V72" name="who" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="85" EndPos="85" width="1" RecSegNo="1"/>
      <labl>
        Partner who moved in/out (D)
      </labl>
      <valrng>
        <range min="1" max="3"/>
      </valrng>
      <sumStat type="vald">
        38309
      </sumStat>
      <sumStat type="invd">
        158094
      </sumStat>
      <txt>
        <![CDATA[

Who was 'responsible' for the residency start/stop on this date: i.e. who moved in last or out first, or did they move in/out together?]]>
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          6535
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          2127
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          29647
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          158094
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[<Spouse listing (from co-parent links and gen_spouse) are merged into residency episodes, those where there is overlap for the wife and husband in the same household are kept. The start & end dates of the overlapping period are compared to the start and end dates of the wife's/husband's episode to see who moved in/out:>
use ${tempfiles}\parlinks_checked, clear
*add in spouse links
append using ${tempfiles}\spouse_pairs_all_data, keep(wife husband)
duplicates drop
drop if wife=="" | husband==""
rename wife ident
*merge to residency data (wife)
joinby ident using ${gendata}\crs_residency_episodes_clean_poly, unmatched(both) _merge(wifem)
rename (ident startdate stopdate starttype stoptype rsnmovecenm rsnmovedep crshse) (wife w_startdate w_stopdate w_starttype w_stoptype w_rsnstart w_rsnstop w_crshse)
drop sex birth_date
rename husband ident
joinby ident using ${gendata}\crs_residency_episodes_clean_poly, unmatched(both)  _merge(husbandm)
rename (ident startdate stopdate starttype stoptype rsnmovecenm rsnmovedep crshse) (husband h_startdate h_stopdate h_starttype h_stoptype h_rsnstart h_rsnstop h_crshse)
drop sex birth_date
keep if w_crshse==h_crshse & h_startdate~=. & h_stopdate~=. & w_startdate~=. & w_stopdate~=. & ((h_startdate>=w_startdate & h_startdate<=w_stopdate) | (h_stopdate>=w_startdate & h_stopdate<=w_stopdate) | (w_startdate>=h_startdate & w_startdate<=h_stopdate) | (w_stopdate>=h_startdate & w_stopdate<=h_stopdate))
egen resstartdt=rowmax(w_startdate h_startdate)
egen resstopdt=rowmin(w_stopdate h_stopdate)
format %td resstartdt resstopdt
la def whost 1 "wife" 2 "husband" 3 "both"
foreach st in start stop {
	gen who`st'=1 if res`st'dt==w_`st'date
	replace who`st'=2 if res`st'dt==h_`st'date
	replace who`st'=3 if res`st'dt==w_`st'date & res`st'dt==h_`st'date
	la val who`st' whost
	replace h_`st'rsn=. if who`st'==1
	replace w_`st'rsn=. if who`st'==2
	}]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V73" name="type" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="86" EndPos="86" width="1" RecSegNo="1"/>
      <labl>
        Type of residency data (D)
      </labl>
      <valrng>
        <range min="1" max="2"/>
      </valrng>
      <sumStat type="vald">
        38309
      </sumStat>
      <sumStat type="invd">
        158094
      </sumStat>
      <txt>
        Type of residency data
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          ep end
        </labl>
        <catStat type="freq">
          16753
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          ep start
        </labl>
        <catStat type="freq">
          21556
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          158094
        </catStat>
      </catgry>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V74" name="rmardate" files="F4" intrvl="discrete">
      <location StartPos="87" EndPos="96" width="10" RecSegNo="1"/>
      <labl>
        Date known to be married with residency data (D)
      </labl>
      <sumStat type="vald">
        33259
      </sumStat>
      <txt>
        Date known to be married with residency data
      </txt>
      <codInstr>
        <![CDATA[<couple are assumed to be married according to residency data if date is the start of a co-resident episode, or if the reason for the end of episode is not birth/death nor divorce:>
gen rmardate=rdate if type==2 | (type==1 & w_rsn~=2 & w_rsn~=4 & h_rsn~=2 & h_rsn~=4)]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V75" name="rsepdate" files="F4" intrvl="discrete">
      <location StartPos="97" EndPos="106" width="10" RecSegNo="1"/>
      <labl>
        Date known to be separated with residency data (D)
      </labl>
      <sumStat type="vald">
        5050
      </sumStat>
      <txt>
        Date known to be separated with residency data
      </txt>
      <codInstr>
        <![CDATA[<couple is assumed to have separated if reason for end of co-residency episode is birth/death or divorce:>
gen rsepdate=rdate if type==1 & (w_rsn==2 | w_rsn==4 | h_rsn==2 | h_rsn==4)]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V76" name="w_rsn" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="107" EndPos="107" width="1" RecSegNo="1"/>
      <labl>
        Wife's reason for res ep start/stop (D)
      </labl>
      <valrng>
        <range min="1" max="7"/>
      </valrng>
      <sumStat type="vald">
        36166
      </sumStat>
      <sumStat type="invd">
        160237
      </sumStat>
      <txt>
        Wife's reason for res ep start/stop
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Baseline/present
        </labl>
        <catStat type="freq">
          11079
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Birth/Death
        </labl>
        <catStat type="freq">
          343
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Migr - marriage
        </labl>
        <catStat type="freq">
          9618
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Migr - Div/Sep
        </labl>
        <catStat type="freq">
          3888
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          Migr - educ
        </labl>
        <catStat type="freq">
          97
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          Migr - work
        </labl>
        <catStat type="freq">
          6091
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          7
        </catValu>
        <labl>
          Migr - other
        </labl>
        <catStat type="freq">
          5050
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          160237
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: rsnmovecenm (table[s]: crs_residency_episodes_clean_poly [derived table])
variable: rsnmovedep (table[s]: crs_residency_episodes_clean_poly [derived table])

<the rsnmove variables from crs_residency_episodes_clean_poly are first renamed to w_stoprsn/h_startrsn etc.>
la def strsn 1 "Baseline/present" 2 "Birth/Death" 3 "Migr - marriage" 4 "Migr - Div/Sep" 5 "Migr - educ" 6 "Migr - work" 7 "Migr - other"
foreach s in w h {
	foreach st in start stop {
		gen `s'_`st'rsn=1 if `s'_`st'type==1
		replace `s'_`st'rsn=2 if `s'_`st'type==2
		replace `s'_`st'rsn=3 if (`s'_`st'type==3 | `s'_`st'type==4) & `s'_rsn`st'==1
		replace `s'_`st'rsn=4 if (`s'_`st'type==3 | `s'_`st'type==4) & `s'_rsn`st'==2
		replace `s'_`st'rsn=5 if (`s'_`st'type==3 | `s'_`st'type==4) & `s'_rsn`st'==3
		replace `s'_`st'rsn=6 if (`s'_`st'type==3 | `s'_`st'type==4) & `s'_rsn`st'==4
		replace `s'_`st'rsn=7 if (`s'_`st'type==3 | `s'_`st'type==4) & (`s'_rsn`st'==5 | `s'_rsn`st'==.)
		la val `s'_`st'rsn strsn
		}
	}]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V77" name="h_rsn" files="F4" dcml="0" intrvl="discrete">
      <location StartPos="108" EndPos="108" width="1" RecSegNo="1"/>
      <labl>
        Husband's reason for res ep start/stop (D)
      </labl>
      <valrng>
        <range min="1" max="7"/>
      </valrng>
      <sumStat type="vald">
        31663
      </sumStat>
      <sumStat type="invd">
        164740
      </sumStat>
      <txt>
        <![CDATA[
Husband's reason for res ep start/stop]]>
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Baseline/present
        </labl>
        <catStat type="freq">
          10446
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Birth/Death
        </labl>
        <catStat type="freq">
          803
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Migr - marriage
        </labl>
        <catStat type="freq">
          6209
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Migr - Div/Sep
        </labl>
        <catStat type="freq">
          1172
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          Migr - educ
        </labl>
        <catStat type="freq">
          135
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          Migr - work
        </labl>
        <catStat type="freq">
          6995
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          7
        </catValu>
        <labl>
          Migr - other
        </labl>
        <catStat type="freq">
          5903
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          164740
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: rsnmovecenm (table[s]: crs_residency_episodes_clean_poly [derived table])
variable: rsnmovedep (table[s]: crs_residency_episodes_clean_poly [derived table])

<the rsnmove variables from crs_residency_episodes_clean_poly are first renamed to w_stoprsn/h_startrsn etc.>
la def strsn 1 "Baseline/present" 2 "Birth/Death" 3 "Migr - marriage" 4 "Migr - Div/Sep" 5 "Migr - educ" 6 "Migr - work" 7 "Migr - other"
foreach s in w h {
	foreach st in start stop {
		gen `s'_`st'rsn=1 if `s'_`st'type==1
		replace `s'_`st'rsn=2 if `s'_`st'type==2
		replace `s'_`st'rsn=3 if (`s'_`st'type==3 | `s'_`st'type==4) & `s'_rsn`st'==1
		replace `s'_`st'rsn=4 if (`s'_`st'type==3 | `s'_`st'type==4) & `s'_rsn`st'==2
		replace `s'_`st'rsn=5 if (`s'_`st'type==3 | `s'_`st'type==4) & `s'_rsn`st'==3
		replace `s'_`st'rsn=6 if (`s'_`st'type==3 | `s'_`st'type==4) & `s'_rsn`st'==4
		replace `s'_`st'rsn=7 if (`s'_`st'type==3 | `s'_`st'type==4) & (`s'_rsn`st'==5 | `s'_rsn`st'==.)
		la val `s'_`st'rsn strsn
		}
	}]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V78" name="w_lastalive" files="F4" intrvl="discrete">
      <location StartPos="109" EndPos="118" width="10" RecSegNo="1"/>
      <labl>
        Last known date wife alive (D)
      </labl>
      <sumStat type="vald">
        196345
      </sumStat>
      <txt>
        Last known date wife alive
      </txt>
      <codInstr>
        <![CDATA[variable: stepdate (table[s]: crs_residency_episodes_clean_poly [derived table])
variable: idmoth (table[s]: parents_lafd [derived table])
variable: idfath (table[s]: parents_lafd [derived table])
variable: m_lastAC (table[s]: parents_lafd [derived table])
variable: m_firstDC (table[s]: parents_lafd [derived table])
variable: f_lastAC (table[s]: parents_lafd [derived table])
variable: f_firstDC (table[s]: parents_lafd [derived table])
variable: event_date (table[s]: indices])
variable: adl (table[s]: indices])

<vital status for people is summarised from indices, crs data and reports of parental status, these are then merged into the main dataset for wives and husbands>
use ${gendata}\crs_residency_episodes_clean_nopoly, clear
bys ident: egen lastincrs=max(stopdate)
bys ident (stopdate): gen laststop=stoptype[_N]
format %td lastincrs
keep ident lastincrs laststop
duplicates drop
gen crs=1
save ${tempfiles}\allcrsmembers, replace
gen adl=1 if laststop==1 | laststop==4
replace adl=2 if laststop==2
rename lastincrs intdate
save ${tempfiles}\adlcrs, replace

*get listing of last alive and death dates from parents
use idmoth idfath m_lastAC m_firstDC f_lastAC f_firstDC using ${gendata}\parents_lafd, clear
expand 2, gen(exp)
drop if idmoth=="" & idfath==""
gen ident=idmoth if exp==0
replace ident=idfath if exp==1
gen lastA=m_lastAC if exp==0
replace lastA=f_lastAC if exp==1
gen firstD=m_firstDC if exp==0
replace firstD=f_firstDC if exp==1
keep ident lastA firstD
drop if ident==""
duplicates drop
save ${tempfiles}\parslafd, replace
*add in data from indices
use ${newstata}\indices, clear
replace intdate=event_date if event_date~=.
append using ${tempfiles}\adlcrs
expand 2 if adl==2, gen(exp)
replace adl=1 if exp==1
keep ident adl intdate
drop if adl>=3
bys ident adl: egen lastA=max(intdate) if adl==1
bys ident adl: egen firstD=min(intdate) if adl==2
append using ${tempfiles}\parslafd
bys ident: egen lastalive=max(lastA)
bys ident: egen firstdead=min(firstD)
keep ident lastalive firstdead
format %td lastalive firstdead
replace firstdead=. if lastalive>firstdead & lastalive~=.
duplicates drop
save ${tempfiles}\indices_lafd, replace]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V79" name="w_firstdead" files="F4" intrvl="discrete">
      <location StartPos="119" EndPos="128" width="10" RecSegNo="1"/>
      <labl>
        First known date wife dead (D)
      </labl>
      <sumStat type="vald">
        8105
      </sumStat>
      <txt>
        <![CDATA[
First known date wife dead]]>
      </txt>
      <codInstr>
        <![CDATA[variable: stepdate (table[s]: crs_residency_episodes_clean_poly [derived table])
variable: idmoth (table[s]: parents_lafd [derived table])
variable: idfath (table[s]: parents_lafd [derived table])
variable: m_lastAC (table[s]: parents_lafd [derived table])
variable: m_firstDC (table[s]: parents_lafd [derived table])
variable: f_lastAC (table[s]: parents_lafd [derived table])
variable: f_firstDC (table[s]: parents_lafd [derived table])
variable: event_date (table[s]: indices])
variable: adl (table[s]: indices])

<vital status for people is summarised from indices, crs data and reports of parental status, these are then merged into the main dataset for wives and husbands>
use ${gendata}\crs_residency_episodes_clean_nopoly, clear
bys ident: egen lastincrs=max(stopdate)
bys ident (stopdate): gen laststop=stoptype[_N]
format %td lastincrs
keep ident lastincrs laststop
duplicates drop
gen crs=1
save ${tempfiles}\allcrsmembers, replace
gen adl=1 if laststop==1 | laststop==4
replace adl=2 if laststop==2
rename lastincrs intdate
save ${tempfiles}\adlcrs, replace

*get listing of last alive and death dates from parents
use idmoth idfath m_lastAC m_firstDC f_lastAC f_firstDC using ${gendata}\parents_lafd, clear
expand 2, gen(exp)
drop if idmoth=="" & idfath==""
gen ident=idmoth if exp==0
replace ident=idfath if exp==1
gen lastA=m_lastAC if exp==0
replace lastA=f_lastAC if exp==1
gen firstD=m_firstDC if exp==0
replace firstD=f_firstDC if exp==1
keep ident lastA firstD
drop if ident==""
duplicates drop
save ${tempfiles}\parslafd, replace
*add in data from indices
use ${newstata}\indices, clear
replace intdate=event_date if event_date~=.
append using ${tempfiles}\adlcrs
expand 2 if adl==2, gen(exp)
replace adl=1 if exp==1
keep ident adl intdate
drop if adl>=3
bys ident adl: egen lastA=max(intdate) if adl==1
bys ident adl: egen firstD=min(intdate) if adl==2
append using ${tempfiles}\parslafd
bys ident: egen lastalive=max(lastA)
bys ident: egen firstdead=min(firstD)
keep ident lastalive firstdead
format %td lastalive firstdead
replace firstdead=. if lastalive>firstdead & lastalive~=.
duplicates drop
save ${tempfiles}\indices_lafd, replace]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V80" name="h_lastalive" files="F4" intrvl="discrete">
      <location StartPos="129" EndPos="138" width="10" RecSegNo="1"/>
      <labl>
        Last known date husband alive (D)
      </labl>
      <sumStat type="vald">
        195687
      </sumStat>
      <txt>
        <![CDATA[
Last known date husband alive]]>
      </txt>
      <codInstr>
        <![CDATA[variable: stepdate (table[s]: crs_residency_episodes_clean_poly [derived table])
variable: idmoth (table[s]: parents_lafd [derived table])
variable: idfath (table[s]: parents_lafd [derived table])
variable: m_lastAC (table[s]: parents_lafd [derived table])
variable: m_firstDC (table[s]: parents_lafd [derived table])
variable: f_lastAC (table[s]: parents_lafd [derived table])
variable: f_firstDC (table[s]: parents_lafd [derived table])
variable: event_date (table[s]: indices])
variable: adl (table[s]: indices])

<vital status for people is summarised from indices, crs data and reports of parental status, these are then merged into the main dataset for wives and husbands>
use ${gendata}\crs_residency_episodes_clean_nopoly, clear
bys ident: egen lastincrs=max(stopdate)
bys ident (stopdate): gen laststop=stoptype[_N]
format %td lastincrs
keep ident lastincrs laststop
duplicates drop
gen crs=1
save ${tempfiles}\allcrsmembers, replace
gen adl=1 if laststop==1 | laststop==4
replace adl=2 if laststop==2
rename lastincrs intdate
save ${tempfiles}\adlcrs, replace

*get listing of last alive and death dates from parents
use idmoth idfath m_lastAC m_firstDC f_lastAC f_firstDC using ${gendata}\parents_lafd, clear
expand 2, gen(exp)
drop if idmoth=="" & idfath==""
gen ident=idmoth if exp==0
replace ident=idfath if exp==1
gen lastA=m_lastAC if exp==0
replace lastA=f_lastAC if exp==1
gen firstD=m_firstDC if exp==0
replace firstD=f_firstDC if exp==1
keep ident lastA firstD
drop if ident==""
duplicates drop
save ${tempfiles}\parslafd, replace
*add in data from indices
use ${newstata}\indices, clear
replace intdate=event_date if event_date~=.
append using ${tempfiles}\adlcrs
expand 2 if adl==2, gen(exp)
replace adl=1 if exp==1
keep ident adl intdate
drop if adl>=3
bys ident adl: egen lastA=max(intdate) if adl==1
bys ident adl: egen firstD=min(intdate) if adl==2
append using ${tempfiles}\parslafd
bys ident: egen lastalive=max(lastA)
bys ident: egen firstdead=min(firstD)
keep ident lastalive firstdead
format %td lastalive firstdead
replace firstdead=. if lastalive>firstdead & lastalive~=.
duplicates drop
save ${tempfiles}\indices_lafd, replace]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V81" name="h_firstdead" files="F4" intrvl="discrete">
      <location StartPos="139" EndPos="148" width="10" RecSegNo="1"/>
      <labl>
        First known date husband dead (D)
      </labl>
      <sumStat type="vald">
        21121
      </sumStat>
      <txt>
        <![CDATA[	
First known date husband dead]]>
      </txt>
      <codInstr>
        <![CDATA[variable: stepdate (table[s]: crs_residency_episodes_clean_poly [derived table])
variable: idmoth (table[s]: parents_lafd [derived table])
variable: idfath (table[s]: parents_lafd [derived table])
variable: m_lastAC (table[s]: parents_lafd [derived table])
variable: m_firstDC (table[s]: parents_lafd [derived table])
variable: f_lastAC (table[s]: parents_lafd [derived table])
variable: f_firstDC (table[s]: parents_lafd [derived table])
variable: event_date (table[s]: indices])
variable: adl (table[s]: indices])

<vital status for people is summarised from indices, crs data and reports of parental status, these are then merged into the main dataset for wives and husbands>
use ${gendata}\crs_residency_episodes_clean_nopoly, clear
bys ident: egen lastincrs=max(stopdate)
bys ident (stopdate): gen laststop=stoptype[_N]
format %td lastincrs
keep ident lastincrs laststop
duplicates drop
gen crs=1
save ${tempfiles}\allcrsmembers, replace
gen adl=1 if laststop==1 | laststop==4
replace adl=2 if laststop==2
rename lastincrs intdate
save ${tempfiles}\adlcrs, replace

*get listing of last alive and death dates from parents
use idmoth idfath m_lastAC m_firstDC f_lastAC f_firstDC using ${gendata}\parents_lafd, clear
expand 2, gen(exp)
drop if idmoth=="" & idfath==""
gen ident=idmoth if exp==0
replace ident=idfath if exp==1
gen lastA=m_lastAC if exp==0
replace lastA=f_lastAC if exp==1
gen firstD=m_firstDC if exp==0
replace firstD=f_firstDC if exp==1
keep ident lastA firstD
drop if ident==""
duplicates drop
save ${tempfiles}\parslafd, replace
*add in data from indices
use ${newstata}\indices, clear
replace intdate=event_date if event_date~=.
append using ${tempfiles}\adlcrs
expand 2 if adl==2, gen(exp)
replace adl=1 if exp==1
keep ident adl intdate
drop if adl>=3
bys ident adl: egen lastA=max(intdate) if adl==1
bys ident adl: egen firstD=min(intdate) if adl==2
append using ${tempfiles}\parslafd
bys ident: egen lastalive=max(lastA)
bys ident: egen firstdead=min(firstD)
keep ident lastalive firstdead
format %td lastalive firstdead
replace firstdead=. if lastalive>firstdead & lastalive~=.
duplicates drop
save ${tempfiles}\indices_lafd, replace]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V17" name="wife" files="F3" intrvl="discrete">
      <location StartPos="1" EndPos="7" width="7" RecSegNo="1"/>
      <labl>
        Unique identifier of wife (D)
      </labl>
      <sumStat type="vald">
        22800
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        Unique identifier of wife
      </txt>
      <codInstr>
        variable: wife (table[s]: all_spouse_pairs_full [derived table])
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V18" name="husband" files="F3" intrvl="discrete">
      <location StartPos="8" EndPos="14" width="7" RecSegNo="1"/>
      <labl>
        Unique identifier of husband (D)
      </labl>
      <sumStat type="vald">
        22800
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        <![CDATA[	
Unique identifier of husband]]>
      </txt>
      <codInstr>
        variable: husband (table[s]: all_spouse_pairs_full [derived table])
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V19" name="repby" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="15" EndPos="15" width="1" RecSegNo="1"/>
      <labl>
        Union ever reported by (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="4"/>
      </valrng>
      <sumStat type="vald">
        21253
      </sumStat>
      <sumStat type="invd">
        1547
      </sumStat>
      <txt>
        Union ever reported by
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          3992
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          1686
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          15575
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Residency data
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          1547
        </catStat>
      </catgry>
      <codInstr>
        variable: repby (table[s]: all_spouse_pairs_full [derived table])
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V20" name="agediff" files="F3" dcml="0" intrvl="contin">
      <location StartPos="16" EndPos="17" width="2" RecSegNo="1"/>
      <labl>
        Age difference between spouses (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="0" max="44"/>
      </valrng>
      <sumStat type="vald">
        22800
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        <![CDATA[	
Age difference between spouses]]>
      </txt>
      <codInstr>
        variable: agediff (table[s]: all_spouse_pairs_full [derived table])
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V21" name="newparlink" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="18" EndPos="18" width="1" RecSegNo="1"/>
      <labl>
        Partnership only from co-parent link (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        22800
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <txt>
        <![CDATA[	
Partnership only from co-parent link]]>
      </txt>
      <codInstr>
        variable: newparlink (table[s]: all_spouse_pairs_full [derived table])
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V22" name="heverpolyn" files="F3" dcml="0" intrvl="contin">
      <location StartPos="19" EndPos="20" width="2" RecSegNo="1"/>
      <labl>
        Max number of spouses husband reports while in this union (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="0" max="99"/>
      </valrng>
      <sumStat type="vald">
        13219
      </sumStat>
      <sumStat type="invd">
        9581
      </sumStat>
      <txt>
        <![CDATA[
Max number of spouses husband reports while in this union]]>
      </txt>
      <codInstr>
        variable: heverpolyn (table[s]: all_spouse_pairs_full [derived table])
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V23" name="everpoly" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="21" EndPos="21" width="1" RecSegNo="1"/>
      <labl>
        Union was ever polygamous (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        13219
      </sumStat>
      <sumStat type="invd">
        9581
      </sumStat>
      <txt>
        Union was ever polygamous (D)
      </txt>
      <codInstr>
        variable: everpoly (table[s]: all_spouse_pairs_full [derived table])
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V24" name="evercur" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="22" EndPos="22" width="1" RecSegNo="1"/>
      <labl>
        Union ever reported to be current (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        21253
      </sumStat>
      <sumStat type="invd">
        1547
      </sumStat>
      <txt>
        <![CDATA[	
Union ever reported to be current]]>
      </txt>
      <codInstr>
        variable: evercur (table[s]: all_spouse_pairs_full [derived table])
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V25" name="mardate" files="F3" intrvl="discrete">
      <location StartPos="23" EndPos="32" width="10" RecSegNo="1"/>
      <labl>
        Marriage date (15-April of reported year) (D)
      </labl>
      <sumStat type="vald">
        14362
      </sumStat>
      <txt>
        <![CDATA[	
Marriage date (15-April of reported year)]]>
      </txt>
      <codInstr>
        <![CDATA[variable: mardate (table[s]: all_spouse_pairs_full [derived table])
variable: rmardate (table[s]: all_spouse_pairs_full [derived table])
variable: rsepdate (table[s]: all_spouse_pairs_full [derived table])

the mode of the reported marriage dates is taken first (this is the date estimated from the marriage start year reported by either partner). It is updated to the earliest co-residency date if this is earlier, or in the same year but different date (as the reported values are all estimated as 15 April).]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V26" name="datatypeM" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="33" EndPos="33" width="1" RecSegNo="1"/>
      <labl>
        mardate datatype (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="6"/>
      </valrng>
      <sumStat type="vald">
        14371
      </sumStat>
      <sumStat type="invd">
        8429
      </sumStat>
      <txt>
        <![CDATA[	
mardate datatype (D)]]>
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Report
        </labl>
        <catStat type="freq">
          9118
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Residency
        </labl>
        <catStat type="freq">
          5253
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Both
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Death
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          8429
        </catStat>
      </catgry>
      <codInstr>
        The datatype variable is updated depending on which final mardate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V27" name="mardtest" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="34" EndPos="34" width="1" RecSegNo="1"/>
      <labl>
        if mardate is estimated (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="0" max="5"/>
      </valrng>
      <sumStat type="vald">
        14371
      </sumStat>
      <sumStat type="invd">
        8429
      </sumStat>
      <txt>
        <![CDATA[	
if mardate is estimated (D)]]>
      </txt>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          No
        </labl>
        <catStat type="freq">
          5253
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Day est
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Day&amp;month
        </labl>
        <catStat type="freq">
          8949
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          est due to overlap
        </labl>
        <catStat type="freq">
          169
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          8429
        </catStat>
      </catgry>
      <codInstr>
        The dtest variable is updated depending on which final mardate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V28" name="informantM" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="35" EndPos="35" width="1" RecSegNo="1"/>
      <labl>
        mardate informant (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="4"/>
      </valrng>
      <sumStat type="vald">
        14371
      </sumStat>
      <sumStat type="invd">
        8429
      </sumStat>
      <txt>
        mardate informant (D)
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          2674
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          480
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          5964
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Residency data
        </labl>
        <catStat type="freq">
          5253
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          8429
        </catStat>
      </catgry>
      <codInstr>
        The informant variable is updated depending on which final mardate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V29" name="fstknwmardate" files="F3" intrvl="discrete">
      <location StartPos="36" EndPos="45" width="10" RecSegNo="1"/>
      <labl>
        First known married date (D)
      </labl>
      <sumStat type="vald">
        8304
      </sumStat>
      <txt>
        <![CDATA[	
First known married date (D)]]>
      </txt>
      <codInstr>
        <![CDATA[variable: stillmardate (table[s]: all_spouse_pairs_full [derived table])
variable: rmardate (table[s]: all_spouse_pairs_full [derived table])
variable: rsepdate (table[s]: all_spouse_pairs_full [derived table])

The earliest date either couple report being married to this partner is used first (i.e. the interview date when the partnership first reported when they are married to them). It is updated to the earliest co-residency date if this is earlier. After all the dates have been finalised this date is removed if mardate is available.]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V30" name="datatypeFM" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="46" EndPos="46" width="1" RecSegNo="1"/>
      <labl>
        fstknwmardate datatype (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="6"/>
      </valrng>
      <sumStat type="vald">
        8304
      </sumStat>
      <sumStat type="invd">
        14496
      </sumStat>
      <txt>
        fstknwmardate datatype (D)
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Report
        </labl>
        <catStat type="freq">
          5916
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Residency
        </labl>
        <catStat type="freq">
          2311
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Both
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Death
        </labl>
        <catStat type="freq">
          77
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          14496
        </catStat>
      </catgry>
      <codInstr>
        The datatype variable is updated depending on which final fstknwmardate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V31" name="fstknwmardtest" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="47" EndPos="51" width="5" RecSegNo="1"/>
      <labl>
        if fstknwmardate is estimated (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="0" max="17800"/>
      </valrng>
      <sumStat type="vald">
        8268
      </sumStat>
      <sumStat type="invd">
        14532
      </sumStat>
      <txt>
        if fstknwmardate is estimated (D)
      </txt>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          No
        </labl>
        <catStat type="freq">
          8041
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Day est
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Day&amp;month
        </labl>
        <catStat type="freq">
          221
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          est due to overlap
        </labl>
        <catStat type="freq">
          4
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          15776
        </catValu>
        <catStat type="freq">
          1
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          17800
        </catValu>
        <catStat type="freq">
          1
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          14532
        </catStat>
      </catgry>
      <codInstr>
        The dtest variable is updated depending on which final fstknwmardate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V32" name="informantFM" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="52" EndPos="52" width="1" RecSegNo="1"/>
      <labl>
        fstknwmardate informant (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="4"/>
      </valrng>
      <sumStat type="vald">
        8304
      </sumStat>
      <sumStat type="invd">
        14496
      </sumStat>
      <txt>
        fstknwmardate informant (D)
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          1547
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          1445
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          2924
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Residency data
        </labl>
        <catStat type="freq">
          2388
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          14496
        </catStat>
      </catgry>
      <codInstr>
        The informant variable is updated depending on which final fstknwmardate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V33" name="stillmardate" files="F3" intrvl="discrete">
      <location StartPos="53" EndPos="62" width="10" RecSegNo="1"/>
      <labl>
        Last date still reported to be married (D)
      </labl>
      <sumStat type="vald">
        15209
      </sumStat>
      <txt>
        Last date still reported to be married
      </txt>
      <codInstr>
        <![CDATA[variable: stillmardate (table[s]: all_spouse_pairs_full [derived table])
variable: rmardate (table[s]: all_spouse_pairs_full [derived table])
variable: rsepdate (table[s]: all_spouse_pairs_full [derived table])

The latest date either couple report being married to this partner is used first (i.e. the interview date when the partnership first reported when they are married to them). It is updated to the latest co-residency date if this is later. After all the dates have been finalised this date is removed if sepdate is available.]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V34" name="datatypeSM" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="63" EndPos="63" width="1" RecSegNo="1"/>
      <labl>
        stillmardate datatype (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="6"/>
      </valrng>
      <sumStat type="vald">
        15209
      </sumStat>
      <sumStat type="invd">
        7591
      </sumStat>
      <txt>
        stillmardate datatype (D)
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Report
        </labl>
        <catStat type="freq">
          6146
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Residency
        </labl>
        <catStat type="freq">
          9063
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Both
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Death
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          7591
        </catStat>
      </catgry>
      <codInstr>
        The datatype variable is updated depending on which final stillmardate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V35" name="stillmardtest" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="64" EndPos="64" width="1" RecSegNo="1"/>
      <labl>
        if stillmardate is estimated (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="0" max="5"/>
      </valrng>
      <sumStat type="vald">
        15178
      </sumStat>
      <sumStat type="invd">
        7622
      </sumStat>
      <txt>
        <![CDATA[	
if stillmardate is estimated (D)]]>
      </txt>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          No
        </labl>
        <catStat type="freq">
          15113
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Day est
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Day&amp;month
        </labl>
        <catStat type="freq">
          40
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          est due to overlap
        </labl>
        <catStat type="freq">
          25
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          7622
        </catStat>
      </catgry>
      <codInstr>
        The dtest variable is updated depending on which final stillmardate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V36" name="informantSM" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="65" EndPos="65" width="1" RecSegNo="1"/>
      <labl>
        stillmardate informant (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="4"/>
      </valrng>
      <sumStat type="vald">
        15209
      </sumStat>
      <sumStat type="invd">
        7591
      </sumStat>
      <txt>
        stillmardate informant (D)
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          1970
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          1869
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          2307
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Residency data
        </labl>
        <catStat type="freq">
          9063
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          7591
        </catStat>
      </catgry>
      <codInstr>
        The informant variable is updated depending on which final stillmardate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V37" name="sepdate" files="F3" intrvl="discrete">
      <location StartPos="66" EndPos="75" width="10" RecSegNo="1"/>
      <labl>
        Separation date (15-Aug of reported year) (D)
      </labl>
      <sumStat type="vald">
        7457
      </sumStat>
      <txt>
        <![CDATA[	
Separation date (15-Aug of reported year)]]>
      </txt>
      <codInstr>
        <![CDATA[variable: sepdate (table[s]: all_spouse_pairs_full [derived table])
variable: rmardate (table[s]: all_spouse_pairs_full [derived table])
variable: rsepdate (table[s]: all_spouse_pairs_full [derived table])
variable: w_firstdead (table[s]: all_spouse_pairs_full [derived table])
variable: h_firstdead (table[s]: all_spouse_pairs_full [derived table])

the mode of the reported separation dates is taken first (this is the date estimated from the marriage end year reported by either partner). It is updated to the latest co-residency date [if the reason for the end of the co-res episode was divorce] if this is later or in the same year but different date. If there is a residency date where they are still thought to be married after the separation date the sepdate is deleted. If the sepdate or stillmardate is on or after the death date for either partner, the sepdate is updated to the death date.]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V38" name="datatypeS" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="76" EndPos="76" width="1" RecSegNo="1"/>
      <labl>
        sepdate datatype (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="6"/>
      </valrng>
      <sumStat type="vald">
        7457
      </sumStat>
      <sumStat type="invd">
        15343
      </sumStat>
      <txt>
        <![CDATA[
sepdate datatype (D)]]>
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Report
        </labl>
        <catStat type="freq">
          2446
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Residency
        </labl>
        <catStat type="freq">
          3486
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Both
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Death
        </labl>
        <catStat type="freq">
          1525
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          15343
        </catStat>
      </catgry>
      <codInstr>
        The datatype variable is updated depending on which final sepdate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V39" name="sepdtest" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="77" EndPos="77" width="1" RecSegNo="1"/>
      <labl>
        if sepdate is estimated (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="0" max="5"/>
      </valrng>
      <sumStat type="vald">
        7330
      </sumStat>
      <sumStat type="invd">
        15470
      </sumStat>
      <txt>
        <![CDATA[	
if sepdate is estimated (D)]]>
      </txt>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          No
        </labl>
        <catStat type="freq">
          4509
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Day est
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Day&amp;month
        </labl>
        <catStat type="freq">
          2731
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          est due to overlap
        </labl>
        <catStat type="freq">
          90
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          15470
        </catStat>
      </catgry>
      <codInstr>
        The dtest variable is updated depending on which final sepdate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V40" name="informantS" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="78" EndPos="78" width="1" RecSegNo="1"/>
      <labl>
        sepdate informant (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="4"/>
      </valrng>
      <sumStat type="vald">
        7457
      </sumStat>
      <sumStat type="invd">
        15343
      </sumStat>
      <txt>
        <![CDATA[
sepdate informant (D)]]>
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          2171
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          256
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          19
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Residency data
        </labl>
        <catStat type="freq">
          5011
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          15343
        </catStat>
      </catgry>
      <codInstr>
        The informant variable is updated depending on which final sepdate is used.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V41" name="died" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="79" EndPos="79" width="1" RecSegNo="1"/>
      <labl>
        Which partner died (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="3"/>
      </valrng>
      <sumStat type="vald">
        1525
      </sumStat>
      <sumStat type="invd">
        21275
      </sumStat>
      <txt>
        <![CDATA[	
Which partner died (D)]]>
      </txt>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          348
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          1177
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          21275
        </catStat>
      </catgry>
      <codInstr>
        Updated to wife or husband if their death date is taken as sepdate
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V42" name="firstrepdate" files="F3" intrvl="discrete">
      <location StartPos="80" EndPos="89" width="10" RecSegNo="1"/>
      <labl>
        First date of any report (D)
      </labl>
      <sumStat type="vald">
        21253
      </sumStat>
      <txt>
        <![CDATA[	
First date reported married (D)]]>
      </txt>
      <codInstr>
        The first date either partner report this union (regardless of whether they reported still being married)
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V43" name="lastrepdate" files="F3" intrvl="discrete">
      <location StartPos="90" EndPos="99" width="10" RecSegNo="1"/>
      <labl>
        Last date of any report (D)
      </labl>
      <sumStat type="vald">
        21253
      </sumStat>
      <txt>
        <![CDATA[	
Last date reported married (D)]]>
      </txt>
      <codInstr>
        The last date either partner report this union (regardless of whether they reported still being married)
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V44" name="firstrepdatecrs" files="F3" intrvl="discrete">
      <location StartPos="100" EndPos="109" width="10" RecSegNo="1"/>
      <labl>
        First date of any report while in the CRS (D)
      </labl>
      <sumStat type="vald">
        16581
      </sumStat>
      <txt>
        <![CDATA[
First date of any report (D)]]>
      </txt>
      <codInstr>
        The first date either partner report this union while they were a CRS member (regardless of whether they reported still being married)
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V45" name="lastrepdatecrs" files="F3" intrvl="discrete">
      <location StartPos="110" EndPos="119" width="10" RecSegNo="1"/>
      <labl>
        Last date of any report while in the CRS (D)
      </labl>
      <sumStat type="vald">
        16581
      </sumStat>
      <txt>
        Last date of any report (D)
      </txt>
      <codInstr>
        The last date either partner report this union while they were a CRS member (regardless of whether they reported still being married)
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V46" name="evercrs" files="F3" dcml="0" intrvl="discrete">
      <location StartPos="120" EndPos="120" width="1" RecSegNo="1"/>
      <labl>
        Either partner ever a CRS member (D)
      </labl>
      <valrng>
        <range UNITS="REAL" min="1" max="1"/>
      </valrng>
      <sumStat type="vald">
        16581
      </sumStat>
      <sumStat type="invd">
        6219
      </sumStat>
      <txt>
        <![CDATA[
First date of any report while in the CRS (D)]]>
      </txt>
      <codInstr>
        gen evercrs=1 if firstrepdatecrs~=.
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V47" name="fstmarrepdate" files="F3" intrvl="discrete">
      <location StartPos="121" EndPos="130" width="10" RecSegNo="1"/>
      <labl>
        First date reported married (D)
      </labl>
      <sumStat type="vald">
        18870
      </sumStat>
      <txt>
        <![CDATA[	
Last date of any report while in the CRS (D)]]>
      </txt>
      <codInstr>
        <![CDATA[variable: stillmardate (table[s]: all_spouse_pairs_full [derived table])

<after all the summary dates are finalised the earliest date either of the partners reported being married to the other partner that is on or after mardate or fstknwmardate is taken:>
egen start=rowmin(mardate fstknwmardate)
bys wife husband: egen temp1=min(stillmardateO) if stillmardateO~=. & stillmardateO>=start
bys wife husband: egen fstmarrepdate=max(temp1)]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V48" name="lstmarrepdate" files="F3" intrvl="discrete">
      <location StartPos="131" EndPos="140" width="10" RecSegNo="1"/>
      <labl>
        Last date reported married (D)
      </labl>
      <sumStat type="vald">
        18673
      </sumStat>
      <txt>
        Either partner ever a CRS member (D)
      </txt>
      <codInstr>
        <![CDATA[variable: stillmardate (table[s]: all_spouse_pairs_full [derived table])

<after all the summary dates are finalised the latest date either of the partners reported being married to the other partner that is on or before sepdate or stillmardate is taken:>
egen end=rowmax(stillmardate sepdate)
bys wife husband: egen temp2=max(stillmardateO) if stillmardateO~=. & stillmardateO<=end
bys wife husband: egen lstmarrepdate=max(temp2)]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V82" name="ident" files="F5" intrvl="discrete">
      <location StartPos="1" EndPos="7" width="7" RecSegNo="1"/>
      <labl>
        Unique identifier
      </labl>
      <sumStat type="vald">
        134177
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <codInstr>
        <![CDATA[variable: wife (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: husband (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: ident (table[s]: all_marstatus_reports [derived table])

<on all_spouse_pairs_clean_summarised:>
expand 2, gen(exp)
gen ident=wife if exp1==0
replace ident=husband if exp1==1
drop if ident==""]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V83" name="sex" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="8" EndPos="8" width="1" RecSegNo="1"/>
      <labl>
        Sex
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        134175
      </sumStat>
      <sumStat type="invd">
        2
      </sumStat>
      <codInstr>
        <![CDATA[variable: sex (table[s]: gen_identity_clear [derived table])

<on all_spouse_pairs_clean_summarised:>
expand 2, gen(exp1)
gen sex=0 if exp1==1
replace sex=1 if exp1==0
<on all_marstatus_reports:>
merge m:1 ident using ${newstata}\gen_identity_clean, keep(master match) keepusing(sex) nogen]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V84" name="date1" files="F5" intrvl="discrete">
      <location StartPos="9" EndPos="18" width="10" RecSegNo="1"/>
      <labl>
        Start date of episode (D)
      </labl>
      <sumStat type="vald">
        134177
      </sumStat>
      <codInstr>
        <![CDATA[variable: mardate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: fstknwmardate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: stillmardate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: sepdate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: intdate (table[s]: all_marital_reports [derived table])


The summary dates for all_spouse_pairs_clean_summarised converted to episodes and then combined with episodes created from all_marital_reports and are then processed to remove over-lapping time.]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V85" name="dtest1" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="19" EndPos="19" width="1" RecSegNo="1"/>
      <labl>
        if date1 is estimated (D)
      </labl>
      <valrng>
        <range min="0" max="5"/>
      </valrng>
      <sumStat type="vald">
        134177
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          No
        </labl>
        <catStat type="freq">
          109115
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Day est
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Day&amp;month
        </labl>
        <catStat type="freq">
          20509
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          est due to overlap
        </labl>
        <catStat type="freq">
          198
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          4355
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: mardtest (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: fstknwmardtest (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: stillmardtest (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: sepdtest (table[s]: all_spouse_pairs_clean_summarised [derived table])

This variable is taken from the all_spouse_pairs_clean_summarised and the all_marital_reports datasets, depending on which record is retained for the episode, if the episode starts or ends due to episode censor or split, this variable reflects this.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V86" name="datatype1" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="20" EndPos="20" width="1" RecSegNo="1"/>
      <labl>
        data type of date1 (D)
      </labl>
      <valrng>
        <range min="1" max="6"/>
      </valrng>
      <sumStat type="vald">
        134177
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Report
        </labl>
        <catStat type="freq">
          87850
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Residency
        </labl>
        <catStat type="freq">
          19294
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Both
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Death
        </labl>
        <catStat type="freq">
          1451
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          21388
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          4194
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: datatypeM (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: datatypeFM (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: datatypeSM (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: datatypeS (table[s]: all_spouse_pairs_clean_summarised [derived table])

This variable is taken from the all_spouse_pairs_clean_summarised and the all_marital_reports datasets, depending on which record is retained for the episode, if the episode starts or ends due to episode censor or split, this variable reflects this.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V87" name="ques1" files="F5" intrvl="discrete">
      <location StartPos="21" EndPos="23" width="3" RecSegNo="1"/>
      <labl>
        source if marital status report1 (D)
      </labl>
      <sumStat type="vald">
        58561
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <codInstr>
        <![CDATA[variable: ques (table[s]: all_marital_reports [derived table])

This variable is taken from the all_marital_reports dataset if the start if the episode is due to a report]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V88" name="informant1" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="24" EndPos="24" width="1" RecSegNo="1"/>
      <labl>
        informant of date1 (D)
      </labl>
      <valrng>
        <range min="0" max="9"/>
      </valrng>
      <sumStat type="vald">
        134177
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          proxy
        </labl>
        <catStat type="freq">
          41270
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          self
        </labl>
        <catStat type="freq">
          23340
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          spouse
        </labl>
        <catStat type="freq">
          7215
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          self&amp;spouse
        </labl>
        <catStat type="freq">
          15163
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          res data
        </labl>
        <catStat type="freq">
          20745
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          21388
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          4646
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          9
        </catValu>
        <labl>
          nk if self or proxy
        </labl>
        <catStat type="freq">
          410
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: informantM (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: informantFM (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: informantSM (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: informantS (table[s]: all_spouse_pairs_clean_summarised [derived table])

the informant variables are taken from the all_spouse_pairs_clean_summarised dataset, they are only changed if there is more than one record per date (the average value is used)]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V89" name="rsn1" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="25" EndPos="25" width="1" RecSegNo="1"/>
      <labl>
        more detailed description of date1 (D)
      </labl>
      <valrng>
        <range min="1" max="9"/>
      </valrng>
      <sumStat type="vald">
        134177
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          StatusRep
        </labl>
        <catStat type="freq">
          59022
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Marriage
        </labl>
        <catStat type="freq">
          25373
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          1stRepOfMar
        </labl>
        <catStat type="freq">
          6571
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          LastRepOfMar
        </labl>
        <catStat type="freq">
          7140
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          Divorce
        </labl>
        <catStat type="freq">
          9122
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          Death (sp)
        </labl>
        <catStat type="freq">
          1367
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          7
        </catValu>
        <labl>
          Death (own)
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          8
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          21388
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          9
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          4194
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: mardate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: fstknwmardate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: stillmardate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: sepdate (table[s]: all_spouse_pairs_clean_summarised [derived table])

This variable is taken from the all_spouse_pairs_clean_summarised and the all_marital_reports datasets, depending on which record is retained for the episode, if the episode starts or ends due to episode censor or split, this variable reflects this.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V90" name="marital" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="26" EndPos="26" width="1" RecSegNo="1"/>
      <labl>
        marital status for episode (D)
      </labl>
      <valrng>
        <range min="0" max="9"/>
      </valrng>
      <sumStat type="vald">
        134167
      </sumStat>
      <sumStat type="invd">
        10
      </sumStat>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          Never married
        </labl>
        <catStat type="freq">
          35166
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Married
        </labl>
        <catStat type="freq">
          53656
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Divorced/separated
        </labl>
        <catStat type="freq">
          17841
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Widowed
        </labl>
        <catStat type="freq">
          5040
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          N/A (dead)
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          8
        </catValu>
        <labl>
          Unknown
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          9
        </catValu>
        <labl>
          Missing
        </labl>
        <catStat type="freq">
          22464
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          10
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: mardate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: fstknwmardate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: stillmardate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: sepdate (table[s]: all_spouse_pairs_clean_summarised [derived table])
variable: marital (table[s]: all_marital_reports [derived table])

For episodes created using all_spouse_pairs_clean_summarised within the main marriage dates episode the marital status is married, an episode created using the end date of the main episode has the marital status as divorced or widowed, or unknown depending what is know about the marriage. The episodes created using all_marital_reports use the original marital variable appended. Following cleaning and adding spouse ids marital is updated if required.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V91" name="spousenum" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="27" EndPos="28" width="2" RecSegNo="1"/>
      <labl>
        number of spouses for episode (D)
      </labl>
      <valrng>
        <range min="1" max="99"/>
      </valrng>
      <sumStat type="vald">
        55950
      </sumStat>
      <sumStat type="invd">
        78227
      </sumStat>
      <catgry>
        <catValu>
          97
        </catValu>
        <labl>
          Not applicable
        </labl>
      </catgry>
      <catgry>
        <catValu>
          98
        </catValu>
        <labl>
          Unknown
        </labl>
      </catgry>
      <catgry>
        <catValu>
          99
        </catValu>
        <labl>
          Missing
        </labl>
      </catgry>
      <codInstr>
        <![CDATA[variable: spousenum (table[s]: all_marital_reports [derived table])
variable: idspouse (table[s]: all_spouse_pairs_clean_summarised [derived table])

this come directly from all_marital_reports and is updated once the spouse ids have been added into the episode data.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V92" name="date2" files="F5" intrvl="discrete">
      <location StartPos="29" EndPos="38" width="10" RecSegNo="1"/>
      <labl>
        End date of episode (D)
      </labl>
      <sumStat type="vald">
        134177
      </sumStat>
      <codInstr>
        <![CDATA[variable: date1 (table[s]:this dataset)

The end of date of each episode is the start date of the next episode or 1 year after date1 if the next episode is over 12 months later (or doesn't exist)]]>
      </codInstr>
      <varFormat type="character" formatname="Nesstar.date" schema="other" category="date"/>
    </var>
    <var ID="V93" name="dtest2" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="39" EndPos="43" width="5" RecSegNo="1"/>
      <labl>
        if date2 is estimated (D)
      </labl>
      <valrng>
        <range min="0" max="17800"/>
      </valrng>
      <sumStat type="vald">
        134177
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          No
        </labl>
        <catStat type="freq">
          123505
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Day est
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Day&amp;month
        </labl>
        <catStat type="freq">
          6176
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          est due to overlap
        </labl>
        <catStat type="freq">
          164
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          4331
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          17800
        </catValu>
        <catStat type="freq">
          1
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: dtest1 (table[s]:this dataset)

This variable is taken from the all_spouse_pairs_clean_summarised and the all_marital_reports datasets, depending on which record is retained for the episode, if the episode starts or ends due to episode censor or split, this variable reflects this.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V94" name="datatype2" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="44" EndPos="44" width="1" RecSegNo="1"/>
      <labl>
        data type of date2 (D)
      </labl>
      <valrng>
        <range min="1" max="6"/>
      </valrng>
      <sumStat type="vald">
        134177
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          Report
        </labl>
        <catStat type="freq">
          25812
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Residency
        </labl>
        <catStat type="freq">
          18685
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          Both
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Death
        </labl>
        <catStat type="freq">
          1909
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          83577
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          4194
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: datatype1 (table[s]:this dataset)

This variable is taken from the all_spouse_pairs_clean_summarised and the all_marital_reports datasets, depending on which record is retained for the episode, if the episode starts or ends due to episode censor or split, this variable reflects this.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V95" name="ques2" files="F5" intrvl="discrete">
      <location StartPos="45" EndPos="47" width="3" RecSegNo="1"/>
      <labl>
        source if marital status report2 (D)
      </labl>
      <sumStat type="vald">
        18727
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <codInstr>
        <![CDATA[variable: ques (table[s]: all_marital_reports [derived table])

This variable is taken from the all_marital_reports dataset if the start if the episode is due to a report]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V96" name="informant2" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="48" EndPos="48" width="1" RecSegNo="1"/>
      <labl>
        informant of date2 (D)
      </labl>
      <valrng>
        <range min="0" max="9"/>
      </valrng>
      <sumStat type="vald">
        134177
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <catgry>
        <catValu>
          0
        </catValu>
        <labl>
          proxy
        </labl>
        <catStat type="freq">
          12596
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          self
        </labl>
        <catStat type="freq">
          7638
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          spouse
        </labl>
        <catStat type="freq">
          2399
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          self&amp;spouse
        </labl>
        <catStat type="freq">
          1204
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          res data
        </labl>
        <catStat type="freq">
          20594
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          83577
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          6094
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          9
        </catValu>
        <labl>
          nk if self or proxy
        </labl>
        <catStat type="freq">
          75
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: informant1 (table[s]:this dataset)

This variable is taken from the all_spouse_pairs_clean_summarised and the all_marital_reports datasets, depending on which record is retained for the episode, if the episode starts or ends due to episode censor or split, this variable reflects this.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V97" name="rsn2" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="49" EndPos="49" width="1" RecSegNo="1"/>
      <labl>
        more detailed description of date2 (D)
      </labl>
      <valrng>
        <range min="1" max="9"/>
      </valrng>
      <sumStat type="vald">
        134177
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          StatusRep
        </labl>
        <catStat type="freq">
          19429
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          Marriage
        </labl>
        <catStat type="freq">
          8434
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          1stRepOfMar
        </labl>
        <catStat type="freq">
          2058
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          LastRepOfMar
        </labl>
        <catStat type="freq">
          5811
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          5
        </catValu>
        <labl>
          Divorce
        </labl>
        <catStat type="freq">
          9986
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          6
        </catValu>
        <labl>
          Death (sp)
        </labl>
        <catStat type="freq">
          688
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          7
        </catValu>
        <labl>
          Death (own)
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          8
        </catValu>
        <labl>
          ep censor
        </labl>
        <catStat type="freq">
          83577
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          9
        </catValu>
        <labl>
          ep split
        </labl>
        <catStat type="freq">
          4194
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: rsn1 (table[s]:this dataset)

This variable is taken from the all_spouse_pairs_clean_summarised and the all_marital_reports datasets, depending on which record is retained for the episode, if the episode starts or ends due to episode censor or split, this variable reflects this.]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V98" name="idspouse1" files="F5" intrvl="discrete">
      <location StartPos="50" EndPos="56" width="7" RecSegNo="1"/>
      <labl>
        spouses's id [1] (D)
      </labl>
      <sumStat type="vald">
        48270
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and spouse ids assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V99" name="agediff1" files="F5" dcml="0" intrvl="contin">
      <location StartPos="57" EndPos="58" width="2" RecSegNo="1"/>
      <labl>
        age difference between individual and their spouse [1] (D)
      </labl>
      <valrng>
        <range min="0" max="44"/>
      </valrng>
      <sumStat type="vald">
        48270
      </sumStat>
      <sumStat type="invd">
        85907
      </sumStat>
      <codInstr>
        <![CDATA[variable: agediff (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and agediff for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V100" name="repby1" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="59" EndPos="59" width="1" RecSegNo="1"/>
      <labl>
        who reported the union [1] (D)
      </labl>
      <valrng>
        <range min="1" max="4"/>
      </valrng>
      <sumStat type="vald">
        45241
      </sumStat>
      <sumStat type="invd">
        88936
      </sumStat>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          8156
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          3380
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          33705
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Residency data
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          88936
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: repby (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and repby for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V101" name="parlink1" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="60" EndPos="60" width="1" RecSegNo="1"/>
      <labl>
        whether union only known about through co-parent link and co-residency [1] (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        48270
      </sumStat>
      <sumStat type="invd">
        85907
      </sumStat>
      <codInstr>
        <![CDATA[variable: newparlink (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and parlink for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V102" name="idspouse2" files="F5" intrvl="discrete">
      <location StartPos="61" EndPos="67" width="7" RecSegNo="1"/>
      <labl>
        spouses's id [2] (D)
      </labl>
      <sumStat type="vald">
        2444
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and spouse ids assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V103" name="agediff2" files="F5" dcml="0" intrvl="contin">
      <location StartPos="68" EndPos="69" width="2" RecSegNo="1"/>
      <labl>
        age difference between individual and their spouse [2] (D)
      </labl>
      <valrng>
        <range min="0" max="44"/>
      </valrng>
      <sumStat type="vald">
        2444
      </sumStat>
      <sumStat type="invd">
        131733
      </sumStat>
      <codInstr>
        <![CDATA[variable: agediff (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and agediff for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V104" name="repby2" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="70" EndPos="70" width="1" RecSegNo="1"/>
      <labl>
        who reported the union [2] (D)
      </labl>
      <valrng>
        <range min="1" max="4"/>
      </valrng>
      <sumStat type="vald">
        2372
      </sumStat>
      <sumStat type="invd">
        131805
      </sumStat>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          249
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          211
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          1912
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Residency data
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          131805
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: repby (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and repby for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V105" name="parlink2" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="71" EndPos="71" width="1" RecSegNo="1"/>
      <labl>
        whether union only known about through co-parent link and co-residency [2] (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        2444
      </sumStat>
      <sumStat type="invd">
        131733
      </sumStat>
      <codInstr>
        <![CDATA[variable: newparlink (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and parlink for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V106" name="idspouse3" files="F5" intrvl="discrete">
      <location StartPos="72" EndPos="78" width="7" RecSegNo="1"/>
      <labl>
        spouses's id [3] (D)
      </labl>
      <sumStat type="vald">
        98
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and spouse ids assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V107" name="agediff3" files="F5" dcml="0" intrvl="contin">
      <location StartPos="79" EndPos="80" width="2" RecSegNo="1"/>
      <labl>
        age difference between individual and their spouse [3] (D)
      </labl>
      <valrng>
        <range min="0" max="41"/>
      </valrng>
      <sumStat type="vald">
        98
      </sumStat>
      <sumStat type="invd">
        134079
      </sumStat>
      <codInstr>
        <![CDATA[variable: agediff (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and agediff for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V108" name="repby3" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="81" EndPos="81" width="1" RecSegNo="1"/>
      <labl>
        who reported the union [3] (D)
      </labl>
      <valrng>
        <range min="1" max="4"/>
      </valrng>
      <sumStat type="vald">
        96
      </sumStat>
      <sumStat type="invd">
        134081
      </sumStat>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          10
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          13
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          73
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Residency data
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          134081
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: repby (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and repby for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V109" name="parlink3" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="82" EndPos="82" width="1" RecSegNo="1"/>
      <labl>
        whether union only known about through co-parent link and co-residency [3] (D)
      </labl>
      <valrng>
        <range min="0" max="1"/>
      </valrng>
      <sumStat type="vald">
        98
      </sumStat>
      <sumStat type="invd">
        134079
      </sumStat>
      <codInstr>
        <![CDATA[variable: newparlink (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and parlink for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V110" name="idspouse4" files="F5" intrvl="discrete">
      <location StartPos="83" EndPos="89" width="7" RecSegNo="1"/>
      <labl>
        spouses's id [4] (D)
      </labl>
      <sumStat type="vald">
        12
      </sumStat>
      <sumStat type="invd">
        0
      </sumStat>
      <codInstr>
        <![CDATA[variable: idspouse (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and spouse ids assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="character" schema="other"/>
    </var>
    <var ID="V111" name="agediff4" files="F5" dcml="0" intrvl="contin">
      <location StartPos="90" EndPos="91" width="2" RecSegNo="1"/>
      <labl>
        age difference between individual and their spouse [4] (D)
      </labl>
      <valrng>
        <range min="1" max="33"/>
      </valrng>
      <sumStat type="vald">
        12
      </sumStat>
      <sumStat type="invd">
        134165
      </sumStat>
      <codInstr>
        <![CDATA[variable: agediff (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and agediff for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V112" name="repby4" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="92" EndPos="92" width="1" RecSegNo="1"/>
      <labl>
        who reported the union [4] (D)
      </labl>
      <valrng>
        <range min="1" max="4"/>
      </valrng>
      <sumStat type="vald">
        12
      </sumStat>
      <sumStat type="invd">
        134165
      </sumStat>
      <catgry>
        <catValu>
          1
        </catValu>
        <labl>
          wife
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          2
        </catValu>
        <labl>
          husband
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          3
        </catValu>
        <labl>
          both
        </labl>
        <catStat type="freq">
          12
        </catStat>
      </catgry>
      <catgry>
        <catValu>
          4
        </catValu>
        <labl>
          Residency data
        </labl>
        <catStat type="freq">
          0
        </catStat>
      </catgry>
      <catgry missing="Y">
        <catValu>
          Sysmiss
        </catValu>
        <catStat type="freq">
          134165
        </catStat>
      </catgry>
      <codInstr>
        <![CDATA[variable: repby (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and repby for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
    <var ID="V113" name="parlink4" files="F5" dcml="0" intrvl="discrete">
      <location StartPos="93" EndPos="93" width="1" RecSegNo="1"/>
      <labl>
        whether union only known about through co-parent link and co-residency [4] (D)
      </labl>
      <valrng>
        <range min="0" max="0"/>
      </valrng>
      <sumStat type="vald">
        12
      </sumStat>
      <sumStat type="invd">
        134165
      </sumStat>
      <codInstr>
        <![CDATA[variable: newparlink (table[s]: all_spouse_pairs_clean_summarised [derived table])

Data from all_spouse_pairs_clean_summarised is converted to a wide listing of spouses per person with start and end dates, this is merged into the episode data and parlink for the spouse assigned to the record where they were current spouses]]>
      </codInstr>
      <varFormat type="numeric" schema="other"/>
    </var>
  </dataDscr>
</codeBook>
