TEDS Data Dictionary

Derived Variables in the 1st Contact Dataset

This page gives a listing of derived variables in the 1st Contact dataset, in alphabetical order of variable name. For each variable, a short written description is followed by a box containing the SPSS syntax that was used to derive the variable.

This page does not include descriptions of background variables that are derived from other sources and that are included in the 1st Contact dataset. For information about such variables, see pages describing background variables, exclusions and scrambled IDs.

List of variables described on this page

Click on a variable name in the table below to go to the description on this page. Alternatively, scroll down and find variables in alphabetical order.

Definitions of derived variables

Listed alphabetically

aadults

Category of family, in terms of adult parent figures present (see syntax below for coding).
Derived from item variables describing sex, marital status and relationship to the twins of the respondent (aresp) and partner (apart). Before this derivation, these item variables have been extensively cleaned in order to remove contradictory responses and to replace missing values where they could be inferred.

* Variable to denote household type.
* Variable aadults denotes adult parents present in the home.
* Based on respondent and partner relationships to twins and marital status.
* after cleaning to correct discrepancies in an earlier script.
* Use the same coding as at ages 7 (gadults) and 9 (iadults).
* Start with default value 9=unknown or other.
COMPUTE aadults = 9.
EXECUTE.
* Code 1: Both biological parents present.
* (respondent and partner are mother/father living with other parent).
* Very common, around 90% of cases.
IF (aresprel = 1 & arespstat = 1 & apartrel = 2 & apartstat = 1) aadults = 1.
IF (aresprel = 2 & arespstat = 1 & apartrel = 1 & apartstat = 1) aadults = 1.
EXECUTE.
* Code 2: parent (mother or father, usually mother) living with other/guardian.
* Uncommon, less than 100 families.
IF (ANY(aresprel,1,2) & arespstat = 2) aadults = 2.
IF (ANY(apartrel,1,2) & apartstat = 2) aadults = 2.
EXECUTE.
* Code 3: single parent (mother, father or other, usually mother).
* Quite common, around 1000 families.
IF (ANY(arespstat,3,4,5,6)) aadults = 3.
EXECUTE.
* Code 4: mother is present but marital status and partner details.
* are all missing (could be single mother or could have chosen.
* not to provide any partner details).
* There are over 200 families with such responses.
IF (arespsex = 0 & aresprel = 1 & SYSMIS(arespstat)) aadults = 4.
EXECUTE.
* This leaves no more than 10 families in the unknown/other category.
* Variable apartstat has been used above but in fact is now redundant.
* so drop it at the end of this script.
aalgzyg, aalg2zy

Estimated zygosity, derived using the zygosity algorithm from 1st Contact questionnaire data.
Variable aalg2zy is the zygosity derived from the questionnaire alone, while variable aalgzyg also takes twin sexes into account.
See comments in syntax for details of derivation. Computed from derived variable atempzyg (described elsewhere on this page), from admin twin sex items sex1/2, and from various item variables from the zygosity questionnaire.

* Start with default value of 5 (indeterminate).
COMPUTE aalgzyg = 5.
EXECUTE.
* Do twins have different sexes (1Y 0N).
COMPUTE sexdif = ABS(sex1 - sex2).
EXECUTE.
* Now use the difference score: 0.64 or less means MZ.
* 0.70 or more means DZ.
IF (atempzyg <= 0.64) aalgzyg = 1.
IF (atempzyg >= 0.70) aalgzyg = 2.
EXECUTE.
* Now over-rule the score and conclude DZ if there are clear differences.
* in eye colour, hair shade or hair texture, or if they look very different. 
IF (azyhairs = 3 | azyhairt = 3 | azyeyes = 3 | azypeas = 3) aalgzyg = 2.
EXECUTE.
* Also over-rule score if alike as two peas in a pod (conclude MZ).
IF (azypeas = 1) aalgzyg = 1.
EXECUTE.
* But if the latter clashes with clear differences in hair/eyes.
* then the result is inconsistent (value 99).
IF ((azypeas = 1) & (azyhairs = 3 | azyhairt = 3 | azyeyes = 3)) aalgzyg = 99.
EXECUTE.
* Copy the result into a second variable representing the derived.
* zygosity without reference to information about twin sexes.
* This will be used for admin purposes, to track changes in estimated.
* zygosity for pairs where the twin sexes are updated.
COMPUTE aalg2zy = aalgzyg.
EXECUTE.
* Finally, for aalgzyg but not aalg2zy, over-rule all other data.
* if twins have opposite sexes (DZ) or sexes are unknown.
IF (sexdif = 1) aalgzyg = 2.
IF (SYSMIS(sexdif)) aalgzyg = 5.
EXECUTE.
ablen1/2

Length of each twin at birth in cm.
The raw items are already recorded in centimetres as an integer, so here we just copy them and remove extreme outliers.

* Lengths are already recorded as integer centimetres.
* Simply copy to new variables but remove extreme outliers.
* (less than 26cm or more than 62cm).
* These look like mistakes rather than genuine extremes of length.
* (and the extreme lows do not have a pattern of low gestation ages).
RECODE MP44cm MP45cm
 (LOWEST THRU 26=SYSMIS) (63 THRU HIGHEST=SYSMIS) (ELSE=COPY)
INTO ablen1 ablen2.
EXECUTE.
acontact

1st Contact data is present; 1=yes 0=no.
This variable is derived after merging all the raw booklet item data, by counting the number of responses.

* Count responses in non-branched item variables.
COUNT numberresponses = aethnic alang atwclub abrstfed1 abrstfed2
 aparfeed arelfeed afrndfee aproffee aothfeedf afussy1 afussy2 afeedgap
 adressim asharerm aslpreg1 aslpreg2 aslpmore aslpwake 
 abed1par abed2par abedrel abedfrnd abedprof 
 awork alookpar alookrel alookfrn alookpro alookels aaloneh1 aaloneh2
 aapart anyngmsi anoldmsi anyngfsi anoldfsi apreg
 arespsex aresprel arespbd arespbm arespby aresphqual
 arespjob arespsoc arespclas arespspq arespwork arespstat 
 apartsex apartrel apartbd apartbm apartby aparthqual
 apartjob apartsoc apartclas apartspq apartwork apartstat 
 afert ameds asmoke adiet adrink astress arestdd
 asick1x asick2x asick3x asick4x asick5x asick6x asick7x asick8x 
 agestage ainduced alabourh abdrug abcomp acaes abgap
 ablen1 ablen2 akidgr1 akidgr2 abprob1 abprob2 aspcard1 aspcard2 
 ahospd1 ahospd2 aoutp1 aoutp2 aover1 aover2
 amprob1 amprob2 aphys1 aphys2 agenpro1 agenpro2 avispro1 avispro2
 afits1 afits2 ahand1 ahand2 ahprob1 ahprob2 ahcold1 ahcold2 
 ahcatar1 ahcatar2 ahscrat1 ahscrat2 ahsore1 ahsore2 ahpus1 ahpus2 
 ahmouth1 ahmouth2 ahsnore1 ahsnore2 (0 THRU HIGHEST).
EXECUTE.
* There are cases with no data, caused by the return dates file.
* There are also 4 cases with just aethnic and alang (still useful).
* and 3 cases with only 20-25 items of data (still useful).
* Delete cases with no data.
FILTER OFF.
USE ALL.
SELECT IF (numberresponses > 0).
EXECUTE.
* The remainder all have at least some useful data: add the 1st contact data flag.
COMPUTE acontact = 1.
EXECUTE.
adadage, adadagetw, amumage, amumagetw

Ages of father (adadagetw) and mother (amumagetw) when the twins were born, and ages of father (adadage) and mother (amumage) when the 1st Contact booklets were completed, all rounded to the nearest year.
Derived from respondent birth date (abirresp) or partner birth date (abirpart) if either is reported as being the mother of the twins (aresprel, apartrel), in combination with the booklet completion date (bookletdate) and the twin birth date (aonsdob). All date variables are treated as temporary and are not retained in the dataset. These parent ages are also cleaned to remove extreme outliers less than 13 years and, for mother age at birth of twins, greater than 46 years (steps not shown below).

* Respondent birthdate could be for either mother or father.
* determined by relationship to twins (1=mother, 2=father).
DO IF (aresprel = 1).
 COMPUTE abirmum = abirresp.
ELSE IF (aresprel = 2).
 COMPUTE abirdad = abirresp.
END IF.
* Likewise for partner birthdate.
DO IF (apartrel = 1).
 COMPUTE abirmum = abirpart.
ELSE IF (apartrel = 2).
 COMPUTE abirdad = abirpart.
END IF.
EXECUTE.
* Now use the mother/father birth dates to derive the ages.
COMPUTE amumage = RND(((DATEDIFF(bookletdate, abirmum, "days")) / 365.25), 1) .
COMPUTE adadage = RND(((DATEDIFF(bookletdate, abirdad, "days")) / 365.25), 1) .
COMPUTE amumagetw = RND(((DATEDIFF(aonsdob, abirmum, "days")) / 365.25), 1) .
COMPUTE adadagetw = RND(((DATEDIFF(aonsdob, abirdad, "days")) / 365.25), 1) .
EXECUTE.
afaclas, afajob, afasoc, afaspq, afawork, afahqual and
amoclas, amojob, amosoc, amospq, amowork, amohqual

Various items for the father or male parent (afa) and for the mother or female parent (amo).
These items include highest qualifications (hqual) and various work-related items (job, spq, work, soc, clas).
These variables are copied from raw items for the respondent (aresp) or the partner (apart) as appropriate, according to the apparent sex and relationship to the twins of each.

* First we need to determine whether respondent and partner are mother/female (1).
* or father/male (2), using new temporary variables 'respondent' and 'partner'.
* The coding below relies on the cleaning of these items done in an earlier script.
* but must cover cases where some items are missing.
* Respondent coding relies on stated sex/relationship to twins.
IF (aresprel = 1 | arespsex = 0) respondent = 1.
IF (aresprel = 2 | arespsex = 1) respondent = 2.
EXECUTE.
* For partner, need to avoid conflicting coding.
* where partner is stated to be of the same sex as the respondent.
* but otherwise rely on stated sex or relationship to twins.
IF (respondent = 1 & (apartrel = 2 | apartsex = 1)) partner = 2.
IF (respondent = 2 & (apartrel = 1 | apartsex = 0)) partner = 1.
EXECUTE.

* Can now copy respondent + partner variables into mother + father variables.
DO IF (respondent = 1).
 COMPUTE amohqual = aresphqual. 
 COMPUTE amojob = arespjob.
 COMPUTE amospq = arespspq.
 COMPUTE amowork = arespwork.
 COMPUTE amosoc = arespsoc.
 COMPUTE amoclas = arespclas.
ELSE IF (respondent = 2).
 COMPUTE afahqual = aresphqual.
 COMPUTE afajob = arespjob.
 COMPUTE afaspq = arespspq.
 COMPUTE afawork = arespwork.
 COMPUTE afasoc = arespsoc.
 COMPUTE afaclas = arespclas.
END IF.
EXECUTE.
DO IF (partner = 1).
 COMPUTE amohqual = aparthqual.
 COMPUTE amojob = apartjob.
 COMPUTE amospq = apartspq.
 COMPUTE amowork = apartwork.
 COMPUTE amosoc = apartsoc.
 COMPUTE amoclas = apartclas.
ELSE IF (partner = 2).
 COMPUTE afahqual = aparthqual.
 COMPUTE afajob = apartjob.
 COMPUTE afaspq = apartspq.
 COMPUTE afawork = apartwork.
 COMPUTE afasoc = apartsoc.
 COMPUTE afaclas = apartclas.
END IF.
EXECUTE.
akidgr1/2

Weight of twin at birth in grams (integer values).
Computed from raw item data provided in decimal kilograms. The raw data contain some extreme high outliers that are likely to be mistakes, and these are removed.

* Raw weights are in decimal kilograms - convert to integer grams.
* and round to the nearest 10 (nearly all are recorded like this in the raw data).
COMPUTE akidgr1 = RND((1000 * MP48kg), 10).
COMPUTE akidgr2 = RND((1000 * MP49kg), 10).
EXECUTE. 
* Now delete extreme high outliers that look like mistakes.
* (over 4250 grams) perhaps caused by confusion over units.
RECODE akidgr1 akidgr2 (4250 THRU HIGHEST=SYSMIS).
EXECUTE.
aLLCage, aLLCdate

Age and date variables derived for use in datasets in the LLC TRE (but not to be used in other datasets). These relate to the completion or return of the 1st Contact booklet.
The LLC date variables contain only the month and year, not the day, as a means of reducing identifiability. The date variables are strings formatted as 'yyyy-mm'. These LLC dates are designed to enable the TEDS measures to be placed in a time sequence with NHS medical diagnosis dates in the data in the TRE.
The LLC age variables are integers measuring the number of months between birth and the given TEDS activity, consistent with the matching LLC date variables.
Variable aonsdob is the twin birth date - the raw date variables are not retained in the dataset.

* First extract year and month as temp variables, from birth date and booklet date.
COMPUTE birthyear = XDATE.YEAR(aonsdob).
COMPUTE bookletyear = XDATE.YEAR(bookletdate).
COMPUTE birthmonth = XDATE.MONTH(aonsdob).
COMPUTE bookletmonth = XDATE.MONTH(bookletdate).
EXECUTE.

* The agreed date format is a string yyyy-mm.
* adding '0' where necessary for two-digit months.
STRING aLLCdate (A7).
IF (bookletmonth < 10) aLLCdate = CONCAT(STRING(bookletyear, F4), '-0', STRING(bookletmonth, F1)).
IF (bookletmonth >= 10) aLLCdate = CONCAT(STRING(bookletyear, F4), '-', STRING(bookletmonth, F2)).
EXECUTE.

* The agreed age variable is in integer months.
* and it must agree with the birth and booklet year/month variables that will be available in the LLC.
COMPUTE aLLCage = (bookletmonth + (bookletyear * 12)) - (birthmonth + (birthyear * 12)).
EXECUTE.
amagechl

Age of mother (in years) at birth of her oldest child.
If an older sib, with same parents as twin, was recorded then use the mother's age on birth of this sibling; otherwise, use the mother's age on birth of the twins.
Derived from dates which are not retained in the data: date of 1st Contact booklet, and birth dates of respondent and partner (converted to mother and father), twins and the oldest sibling. The derivation involves some temporary age variables that are not retained in the dataset, such as oldestsibage and mumageoldestsib.
This age has been cleaned, with extreme outliers removed, and only includes recorded older children if they have the same parents as the twins.
Details of the derivation are shown in the syntax below.

* Mother age at birth of first child.
* Cleaned up with age outliers and bad data removed.
* only using mother ages in the range 13 to 46.

* first convert dd/mm/yyyy integers into date variables.
COMPUTE bookletdate = DATE.DMY(booklet_dd, booklet_mm, booklet_yyyy).
COMPUTE oldestsibdob = DATE.DMY(oldestsibdd, oldestsibmm, oldestsibyy). 
COMPUTE abirresp = DATE.DMY(arespbd, arespbm, arespby).
COMPUTE abirpart = DATE.DMY(apartbd, apartbm, apartby).
EXECUTE.
* booklet date will be used to compute ages.
* but if missing, replace with the admin return date.
IF (SYSMIS(bookletdate)) bookletdate = ReturnDate.
EXECUTE.

* Determine mother and father birth dates.
* Respondent birthdate could be for either mother or father.
DO IF (aresprel = 1).
 COMPUTE abirmum = abirresp.
ELSE IF (aresprel = 2).
 COMPUTE abirdad = abirresp.
END IF.
* Likewise for partner birthdate.
DO IF (apartrel = 1).
 COMPUTE abirmum = abirpart.
ELSE IF (apartrel = 2).
 COMPUTE abirdad = abirpart.
END IF.
EXECUTE.

* Now derive ages at 1st Contact: mother, twins and oldest sibling.
COMPUTE amumage = RND(((DATEDIFF(bookletdate, abirmum, "days")) / 365.25), 0.1) .
COMPUTE atwinage = RND(((DATEDIFF(bookletdate, aonsdob, "days")) / 365.25), 0.1) .
COMPUTE oldestsibage = RND(((DATEDIFF(bookletdate, oldestsibdob, "days")) / 365.25), 0.1) .
EXECUTE.
* Use subtraction to find mother's age when children were born.
COMPUTE mumageoldestsib = RND(((DATEDIFF(oldestsibdob, abirmum, "days")) / 365.25), 0.1) .
COMPUTE amumagetw = RND(((DATEDIFF(aonsdob, abirmum, "days")) / 365.25), 0.1) .
EXECUTE.

* Clean up some extreme age outliers which may well be bad data.
* Remove all mother ages less than 13 or greater than 46.
* when children were born (these are very rare).
RECODE amumagetw mumageoldestsib
 (LOWEST THRU 12.9=SYSMIS) (46.1 THRU HIGHEST=SYSMIS).
EXECUTE.

* Now work out mum's age at birth of eldest known child.
* Start with mother age at birth of twins, by default.
COMPUTE amagechl = amumagetw.
EXECUTE.
* Now if older siblings exist (with the same parents as the twins).
* and checking that this sibling's age is older than the twin age.
* then change amagechl to the age when the oldest sibling was born.
IF (mumageoldestsib < amagechl) amagechl = mumageoldestsib.
EXECUTE.
* Round to the nearest year.
COMPUTE amagechl = RND(amagechl, 1).
EXECUTE.
amedtot

Maternal medical risk factors composite scale (standardised).
Computed from 11 different mother-specific item and derived variables relating to pregnancy and birth of the twins.
The sample is filter to remove exclusions (pair-wise) for computation of this composite.

* apply filter to remove exclusions (medical, perinatal, unknown sex/zyg).
* this will affect all standardised variables derived below.
USE ALL.
COMPUTE filter_$=(exclude1 = 0 & exclude2 = 0).
VARIABLE LABELS filter_$ 'exclude1 = 0 & exclude2 = 0 (FILTER)'.
VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'.
FORMATS filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE.

* Standardise all contributing items on this filtered sample.
* Use cleaned/recoded versions (outliers removed) where available.
DESCRIPTIVES VARIABLES=  afert (zafert) agestage (zagestage)
  asick2x (zasick2x) asick4x (zasick4x) asick5x (zasick5x) asick7x (zasick7x)
  ameds (zameds) arestdd (zarestdd) astress (zastress)
  asmokenu (zasmokenu) adrinknu (zadrinknu)
 /SAVE .

* Get reversed versions of standardised fertility treatment
* and gestation age variables.
COMPUTE zafertr = -1 * (zafert).
COMPUTE zagestager = -1 * (zagestage) .
EXECUTE.

* Compute sub-scales for related groups of maternal medical problems.
* Require at least half to be present.
COMPUTE hbptox = MEAN.1(zasick2x, zasick4x) .
COMPUTE birtprob = MEAN.1(zagestager, zasick7x) .
COMPUTE rest = MEAN.2(zasick5x, zarestdd, zameds, zastress) .
COMPUTE drugmum = MEAN.2(zafertr, zasmokenu, zadrinknu) .
EXECUTE.
* Now standardise them.
DESCRIPTIVES VARIABLES= hbptox (zhbptox) birtprob (zbirtprob)
 rest (zrest) drugmum (zdrugmum) /SAVE.

* Maternal Medical Risk Factor scale.
* Mean of the above 4 sub-scales, requiring 2 to be non-missing.
COMPUTE medtot = MEAN.2(zhbptox, zbirtprob, zrest, zdrugmum) .
EXECUTE .
* Standardise it.
DESCRIPTIVES VARIABLES= medtot (amedtot) /SAVE.

* remove filter.
FILTER OFF.
USE ALL.
EXECUTE.
amoclas, amojob, amohqual, amosoc, amospq, amowork

See afaclas, etc above

amumage, amumagetw

See adadage, etc above.

apartage, arespage

Ages of respondent (aresp) and partner (apart) in years, when 1st Contact booklet completed.
Computed from temporary 1st Contact date variables bookletdate (estimated booklet completion date), abirresp and abirpart (respondent and partner birth dates). These raw date variables are not retained in the dataset.

COMPUTE arespage = RND((DATEDIFF(bookletdate, abirresp ,"days") / 365.25), 1) .
COMPUTE apartage = RND((DATEDIFF(bookletdate, abirpart, "days") / 365.25), 1) .
EXECUTE.
aperi1x, aperi2x, aperi3x, aperi4x, aperi5x, aperinat

Perintal outlier exclusion variables; 1=yes exclude, 0=no.
See comments in syntax for explanation of meanings of variables; aperinat is the overall or combined perinatal exclusion variable.
Derived from variables relating to pregnancy and birth of the twins.

* Perinatal outliers: originally derived using the 1/7000 (3.6SD) rule for either twin.
* (but exclusion applies to the twin pair).

* Start with 5 separate variables.
* aperi1: flag birthweights < 471g.
IF (akidgr1 >= 471 & akidgr2 >= 471) aperi1x = 0.
IF ((akidgr1 < 471) | (akidgr2 < 471)) aperi1x = 1 .
EXECUTE.
* aperi2: flag if over 97 days spent in special care when born (either twin).
* using category 5 in aspcard1/2.
IF ((aspcard1 < 5) & (aspcard2 < 5)) aperi2x = 0.
IF ((aspcard1 >= 5) | (aspcard2 >= 5)) aperi2x = 1 .
EXECUTE.
* aperi3: flag if over 74 days spent in hospital (even if not in special care).
* after birth, for either twin, using category 7 of ahospd1/2.
IF (ahospd1 < 7 & ahospd2 < 7) aperi3x = 0.
IF ((ahospd1 >= 7) | (ahospd2 >= 7)) aperi3x = 1.
EXECUTE.
* aperi4: flag if gestation less than 27 weeks.
RECODE agestage (LOWEST THRU 26=1) (27 THRU HIGHEST=0)
INTO aperi4x.
EXECUTE.
* aperi5: maternal drinking >= 14units/week (adrinknu category 7).
IF (adrink = 0 | adrinknu < 7) aperi5x = 0.
IF (adrinknu >= 7) aperi5x = 1.
EXECUTE.
* Now add an overall perinatal outlier exclusion variable aperinat.
COMPUTE aperinat = 0.
EXECUTE.
* Assume excluded if all 5 variables are missing (this is very rare, 26 pairs).
* These are parents who filled in just a few parts of the booklet.
* so can be excluded as if they would be with acontact=0.
IF (SYSMIS(aperi1x) & SYSMIS(aperi2x) & SYSMIS(aperi3x)
 & SYSMIS(aperi4x) & SYSMIS(aperi5x)) aperinat = 1.
EXECUTE.
* Now exclude if the twin pair falls into any one or more of the 5 categories.
IF (SUM(aperi1x, aperi2x, aperi3x, aperi4x, aperi5x) > 0) aperinat = 1.
EXECUTE.
arespage

See apartage, arespage above.

ases

Family SES composite scale (standardised).
Computed from 5 different derived variables relating to parent qualifications and employment and mother's age at birth of first child. See comments in syntax for further explanation.
The sample is filtered using twin exclusion variables exclude1/2, to remove exclusions for computation of this composite.
(Derived variables afahqual, afasoc, amohqual, amosoc and amagechl are described elsewhere on this page.)

* Apply filter to remove exclusions (medical, perinatal, unknown sex/zyg).
* for the twin pair.
USE ALL.
COMPUTE filter_$=(exclude1 = 0 & exclude2 = 0).
VARIABLE LABELS filter_$ 'exclude1 = 0 & exclude2 = 0 (FILTER)'.
VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'.
FORMATS filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE.

* Standardise all contributing items on this filtered sample.
DESCRIPTIVES VARIABLES= afahqual (zafahqual) afasoc (zafasoc)
  amohqual (zamohqual) amosoc (zamosoc) amagechl (zamagechl)
 /SAVE .

* Get reversed versions of standardised parent SOC scores.
COMPUTE zafasocr = -1 * (zafasoc) .
COMPUTE zamosocr = -1 * (zamosoc) .
EXECUTE.

* SES composite 'ases'.
* Mean of 5 standardised SES ratings: mother and father qualification level.
* mother and father SOC (reversed) and mum age on birth of first child.
COMPUTE ses = MEAN.3(zafahqual, zamohqual, zafasocr, zamosocr, zamagechl) .
EXECUTE.
* Standardise it.
DESCRIPTIVES VARIABLES= ses (ases) /SAVE. 

* remove filter.
FILTER OFF.
USE ALL.
EXECUTE.
atempzyg

Zygosity difference score, used in the zygosity algorithm.
The score is scaled to have values between 0 and 1, with higher values representing greater differences between the twins.
Computed from 20 different item and derived variables relating to twin differences. All contributing variables are ordinal, with higher values for greater differences.
(Derived variables azyfac and azytyp are described elsewhere on this page.)

* Compute difference sum, from ordinal variables with higher values = more different.
COMPUTE sumzyg = SUM(azyprof, azyyou, azyhairs, azyhairt, azyeyes, azyears,
 azyteetr, azyold, azyphotr, azyfac, azytyp, azymistp, azymists, azymistr,
 azymistb, azymistf, azymistc, azymistm, azytoget, azypeas).
EXECUTE.
* Determine maximum possible score, depending on number of non-missing.
* responses in the above variables (total is 54 if none missing).
COUNT zyg1 = azyfac azytyp (0 thru 1).
COUNT zyg2 = azyprof azyyou azyteetr (1 thru 2).
COUNT zyg3 = azyhairs azyhairt azyeyes azyears azyold azyphotr azymistp
 azymists azymistr azymistb azymistf azymistc azymistm azypeas (1 thru 3).
COUNT zyg4 = azytoget (1 thru 4).
EXECUTE.
COMPUTE zygtot = SUM(zyg1, (2 * zyg2), (3* zyg3), (4 * zyg4)).
EXECUTE.
* Can now re-scale difference score to range 0-1.
* requiring at least half the data to be non-missing.
* (total possible score must be 27 or higher).
IF (zygtot >= 27) atempzyg = sumzyg / zygtot.
EXECUTE.
atwinage

Age of twins (in years) when the 1st Contact booklet was completed.
Computed from temporary date variables bookletdate (estimated booklet completion date) and abirtwin (twin birth date), which are not retained in the dataset.

COMPUTE atwinage = RND(((DATEDIFF(bookletdate, aonsdob, "days")) / 365.25), 0.1) .
EXECUTE.
atwmed1/2

Twin medical risk factors composite scale (standardised).
Computed from 4 different twin-specific variables relating to twin birth factors.
The sample is filtered to remove exclusions (pair-wise) for computation of this composite.

* apply filter to remove exclusions (medical, perinatal, unknown sex/zyg).
* for the twin pair; this will affect all standardised variables derived below.
USE ALL.
COMPUTE filter_$=(exclude1 = 0 & exclude2 = 0).
VARIABLE LABELS filter_$ 'exclude1 = 0 & exclude2 = 0 (FILTER)'.
VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'.
FORMATS filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE.

* Standardise all contributing items on this filtered sample.
* Use cleaned/recoded versions (outliers removed) where available.
DESCRIPTIVES VARIABLES=  aspcard1 (zaspcard1) aspcard2 (zaspcard2)
  ahospd1 (zahospd1) ahospd2 (zahospd2)
  akidgr1 (zakidgr1) akidgr2 (zakidgr2)
  amprob1 (zamprob1) amprob2 (zamprob2)
 /SAVE .

* Get reversed version of standardised twin birth weight.
COMPUTE zakidgr1r = -1 * (zakidgr1) .
COMPUTE zakidgr2r = -1 * (zakidgr2) .
EXECUTE.

* Twin Medical Risk Factor scale.
* Mean of standardised versions of days in special care.
* days in hospital, reversed twin birth weight and medical problems.
* Require at least two of these to be non-missing.
COMPUTE twmed1 = MEAN.2(zaspcard1, zahospd1, zakidgr1r, zamprob1) .
COMPUTE twmed2 = MEAN.2(zaspcard2, zahospd2, zakidgr2r, zamprob2) .
EXECUTE.
* Standardise in the final version.
DESCRIPTIVES VARIABLES= twmed1 (atwmed1) twmed2 (atwmed2) /SAVE.

* remove filter.
FILTER OFF.
USE ALL.
EXECUTE.
azyfac, azytyp

Do twins have different blood groups (azytyp) and rhesus factors (azyfac); 0=no 1=yes.
Computed from raw item variables for individual twin blood groups and rhesus factors - these raw item variables are not retained in the dataset.

* 0=same 1=different variables for blood group and type.
* missing if either twin variable is missing.
IF (azyfac1 = azyfac2) azyfac = 0.
IF (azyfac1 ~= azyfac2) azyfac = 1.
EXECUTE.
IF (azygp1 = azygp2) azytyp = 0.
IF (azygp1 ~= azygp2) azytyp = 1.
EXECUTE.