TEDS Data Dictionary

Derived Variables in the 16 Year Dataset

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

Most variables described on this page were derived prior to double entering the dataset. The variable name suffix "1" or "2" (to denote twin and co-twin) was added to each twin-specific variable in a later script, hence is not generally shown in the syntax on this page.

This page does not include descriptions of background variables that are derived from other sources and that are included in the 16 Year 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

p16year

Flag variable to show the presence of 16 year data, of any kind, for a given twin pair.
This variable was computed after merging together the data from all sources (web data, behaviour booklet data, and twin exam result data), and after double entering and selecting twin pairs having any of these data for the parent or for one or both twins.

* make a temporary flag variable to show presence of data for either twin in the pair.
COMPUTE ptwindata = 0.
EXECUTE.
IF (pcbhdata1 = 1 | pcbhdata2 = 1 | pcl2data1 = 1 | pcl2data2 = 1
 | pcexdata1 = 1 | pcexdata2 = 1) ptwindata = 1.
EXECUTE.

* only keep cases with parent, web or twin data.
FILTER OFF.
USE ALL.
SELECT IF (ppconsent = 1 | ppbhdata = 1 | ppl2data = 1 | ptwindata = 1).
EXECUTE.

* Add a flag variable to show presence of any 16 year data.
COMPUTE p16year = 1.
EXECUTE.
pcambim1/2, pcgritcoim1/2, pcgritperm1/2, pcgritm1/2

Grit and Ambition scales.
Derived from items (reversed where necessary) of the GRIT and Ambition measure in child web environment and wellbeing questionnaire part D.
The GRIT part of the measure has a total scale (8 items) plus two subscales; the Ambition part of the measure just has a total scale (5 items).
All items have integer values 1-5, and the scales are means so have the same range but with decimal values.

* Consistency of Interest subscale (items 2, 5, 7, 8).
COMPUTE pcgritcoim = MEAN.2(pcqdgrit02r, pcqdgrit05r, pcqdgrit07r, pcqdgrit08r).
EXECUTE.
* Perseverance subscale (items 4, 6, 9, 13).
COMPUTE pcgritperm = MEAN.2(pcqdgrit04, pcqdgrit06, pcqdgrit09, pcqdgrit13).
EXECUTE.
* Grit overall total (all 8 items above).
COMPUTE pcgritm = MEAN.4(pcqdgrit02r, pcqdgrit04, pcqdgrit05r, pcqdgrit06, 
    pcqdgrit07r, pcqdgrit08r, pcqdgrit09, pcqdgrit13).
* Ambition subscale (items 1, 3, 10, 11, 12).
COMPUTE pcambim = MEAN.3(pcqdgrit01, pcqdgrit03, pcqdgrit10, pcqdgrit11r, pcqdgrit12).
EXECUTE.
pcatscm1/2

PISA Attitudes to School scale.
Total scale derived from all 4 items (reversed where necessary) of the PISA attitudes to school measure in child web environment and wellbeing questionnaire part B.
Items have integer values 1-4, and the scale is a mean so it has the same range but with decimal values.
In the syntax below, the scale is computed as variable pcatscm, which is later copied into variables pcatscm1/2 on double entry.

* Overall total scale.
COMPUTE pcatscm = MEAN.2(pcqbstsc1r, pcqbstsc2r, pcqbstsc3, pcqbstsc4).
EXECUTE.
pcattaalt1/2, pcattacot1/2, pcattatrt1/2, pcattat1/2

Attachment scales.
Total scale and three subscales.
Derived from items (reversed where necessary) of the attachment measure in child web environment and wellbeing questionnaire part C.
Each item has integer values 0-4, hence the scales have ranges from 0 to (4 * number of items) as they are 'totals' computed by multiplying the mean by the number of items.
In the syntax below, the scales are computed as variables pcattaXXt, which are later copied into variables pcattaXXt1/2 on double entry.

* Trust subscale (items 5,6,8,12,13,14,15,19,20,21).
COMPUTE pcattatrt = 10 * MEAN.5(pcqcatta05r, pcqcatta06, pcqcatta08, pcqcatta12,
 pcqcatta13, pcqcatta14, pcqcatta15, pcqcatta19, pcqcatta20, pcqcatta21).
EXECUTE.
*Communication subscale (items 1,2,3,7,16,17,24,25).
COMPUTE pcattacot = 8 * MEAN.4(pcqcatta01, pcqcatta02, pcqcatta03, pcqcatta07,
 pcqcatta16, pcqcatta17, pcqcatta24, pcqcatta25).
EXECUTE.
*Alienation subscale (items 4,9,10,11,18,22,23).
COMPUTE pcattaalt = 7 * MEAN.4(pcqcatta04r, pcqcatta09r, pcqcatta10r,
 pcqcatta11r, pcqcatta18r, pcqcatta22r, pcqcatta23r).
EXECUTE.
* Total scale (all 25 items).
COMPUTE pcattat = 25 * MEAN.13(pcqcatta01, pcqcatta02, pcqcatta03, pcqcatta04r, pcqcatta05r, pcqcatta06,
 pcqcatta07, pcqcatta08, pcqcatta09r, pcqcatta10r, pcqcatta11r, pcqcatta12,
 pcqcatta13, pcqcatta14, pcqcatta15, pcqcatta16, pcqcatta17, pcqcatta18r,
 pcqcatta19, pcqcatta20, pcqcatta21, pcqcatta22r, pcqcatta23r, pcqcatta24, pcqcatta25).
EXECUTE.
pcbhage1/2, pcl2age1/2 pcexage1/2, pcexgcseage1/2, pcwebage1/2, ppbhage, ppl2age

Age of twin (in decimal years) when various data components were collected:
ppbhage is the age when the parent behaviour/leap booklet was returned;
pcbhage1/2 is the age when the child behaviour/leap booklet was returned;
ppl2age is the age when the parent leap-2 booklet was returned;
pcl2age1/2 is the age when the child leap-2 booklet was returned;
pcwebage1/2 is the mean age during the child web activities;
pcexage1/2 is the age when the child exam results were returned.
Derived from variables representing respective dates, as mentioned in syntax comments; aonsdob is the twin birth date. These date variables are not retained in the dataset.

* Web test age - compute ages on starting and on ending the tests.
COMPUTE pcwebstage1 = (DATEDIFF(pcwebstdt1,aonsdob,"days")) / 365.25 .
COMPUTE pcwebstage2 = (DATEDIFF(pcwebstdt2,aonsdob,"days")) / 365.25 .
COMPUTE pcwebendage1 = (DATEDIFF(pcwebendt1,aonsdob,"days")) / 365.25 .
COMPUTE pcwebendage2 = (DATEDIFF(pcwebendt2,aonsdob,"days")) / 365.25 .
EXECUTE.

* Use the mean of the start and end ages for each twin.
COMPUTE pcwebage1 = RND(MEAN(pcwebstage1, pcwebendage1), 0.1).
COMPUTE pcwebage2 = RND(MEAN(pcwebstage2, pcwebendage2), 0.1).
EXECUTE.

* Behaviour/Leap/Leap-2 study ages (based on date of return of booklets).
COMPUTE ppbhage = RND((DATEDIFF(ppbhrdate, aonsdob, "days")) / 365.25, 0.1) .
COMPUTE pcbhage1 = RND((DATEDIFF(pcbhrdate1, aonsdob, "days")) / 365.25, 0.1) .
COMPUTE pcbhage2 = RND((DATEDIFF(pcbhrdate2, aonsdob, "days")) / 365.25, 0.1) .
COMPUTE ppl2age = RND((DATEDIFF(ppl2rdate, aonsdob, "days")) / 365.25, 0.1) .
COMPUTE pcl2age1 = RND((DATEDIFF(pcl2rdate1, aonsdob, "days")) / 365.25, 0.1) .
COMPUTE pcl2age2 = RND((DATEDIFF(pcl2rdate2, aonsdob, "days")) / 365.25, 0.1) .
EXECUTE.

* Exam results age (based on date of return of GCSE forms).
COMPUTE pcexage1 = RND((DATEDIFF(pcexrdate1, aonsdob, "days")) / 365.25, 0.1) .
COMPUTE pcexage2 = RND((DATEDIFF(pcexrdate2, aonsdob, "days")) / 365.25, 0.1) .
EXECUTE.
* Note that this age tells us very little about when the exams were actually taken.
* so add another variable with approximate GCSE age.
* based on the assumption that GCSEs were taken in June at the end of the school.
* year in which twins reached the age of 16 years.
* This ignores cases where twins might have taken some or all of their GCSEs.
* a year or two early or late, because there is insufficient evidence.
* to know the date when most exams were taken for any given twin.
* Cohort 1: GCSEs should have been taken in June 2010.
* Hence exame year is assumed to be 2009 + cohort.
* Estimate age only to the nearest month, by subtraction.
* and only compute the age if exam data are present.
IF (pcexdata = 1) pcexgcseage = RND((((2009 + cohort) + (6 / 12)) - (birthyear + (birthmonth / 12))), 0.1).
EXECUTE.
pcbhalco21/2, pcl2alco21/2

Estimated number of alcohol units consumed in the past month, for the Leap (pcbh) and Leap-2 (pcl2) equivalent measures. Derived from raw items, where twins reported estimated numbers of drinks of (a) beer/cider, (b) wine and (c) spirits consumed. The derivation is explained in the syntax below.

* Alcohol units (question 2).
* Twin Leap (not cohort 1) and Leap-2 (all cohorts).
* Convert raw items 2a/b/c (numbers of drinks).
* into a more useful single estimate of number of units.
* First use the mid-point of each response range to estimate the number of drinks.
* for each type of drink, e.g. 1-2=1.5, 3-5=4 drinks.
RECODE pcbhalco2a pcbhalco2b pcbhalco2c pcl2alco2a pcl2alco2b pcl2alco2c
 (0=0) (1=1.5) (2=4) (3=8) (4=15) (5=30) (6=60)
INTO pcbhalco2aX pcbhalco2bX pcbhalco2cX pcl2alco2aX pcl2alco2bX pcl2alco2cX.
EXECUTE.
* Now sum to get an approximate total number of units.
* treating each drink of beer or wine (parts a/b) as roughly 2 units.
* and each drink of spirits (part c) as roughly 1 unit.
* Round to an integer because these are estimates.
COMPUTE pcbhalco2 = RND(SUM((2 * pcbhalco2aX), (2 * pcbhalco2bX), pcbhalco2cX)).
COMPUTE pcl2alco2 = RND(SUM((2 * pcl2alco2aX), (2 * pcl2alco2bX), pcl2alco2cX)).
EXECUTE.
pcbhanhdt1/2, pcl2anhdt1/2

Introvertive Anhedonia scale.
Total scale derived from all 7 items (reversed where necessary) of the Introvertive Anhedonia measure in the child behaviour/leap/leap-2 study booklet.
Variables pcbhanhdt1/2 is from behaviour/leap, while pcl2anhdt1/2 is from leap-2.
Each item has integer values 0 and 1, hence the scale has range 0-7 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcbhanhdt (or pcl2anhdt), which is later copied into variables pcbhanhdt1/2 (or pcl2anhdt1/2) on double entry.

* total scale (all 7 items).
COMPUTE pcbhanhdt = 7 * MEAN.4(pcbhanhd1, pcbhanhd2,
 pcbhanhd3r, pcbhanhd4, pcbhanhd5r, pcbhanhd6, pcbhanhd7).
COMPUTE pcl2anhdt = 7 * MEAN.4(pcl2anhd1, pcl2anhd2,
 pcl2anhd3r, pcl2anhd4, pcl2anhd5r, pcl2anhd6, pcl2anhd7).
EXECUTE.
pcbhaqdett1/2, pcbhaqsoct1/2, pcbhaqt1/2, ppbhaqatst1/2, ppbhaqdett1/2, ppbhaqimat1/2, ppbhaqsoct1/2, ppbhaqt1/2

AQ (Autism Quotient) scales.
Parent and child self-report versions: total scale and four subscales.
Derived from items (reversed where necessary) of the AQ measure in the parent and child behaviour booklets.
Note that the parent and child booklet measures included different subsets of the AQ items, hence there are differences between the parent and child scales and subscales.
Each item has integer values 0-3, hence each scale has a range of values from 0 to (3 * number of items) because it is computed as the mean multiplied by the number of component items.
In the syntax below, the child scales are computed as variables pcbhaqXXXt, which are later copied into variables pcbhaqXXXt1/2 on double entry.

* Social scale (parent 9 items, child 8 items).
COMPUTE ppbhaqsoct1 = 9 * MEAN.5(ppbhaq01r1, ppbhaq02r1, ppbhaq031,
 ppbhaq04r1, ppbhaq051, ppbhaq06r1, ppbhaq07r1, ppbhaq22r1, ppbhaq231).
COMPUTE pcbhaqsoct = 8 * MEAN.4(pcbhaq01r, pcbhaq02r, pcbhaq03,
 pcbhaq04r, pcbhaq05, pcbhaq06r, pcbhaq07r, pcbhaq08).
EXECUTE .

* Attention Switching scale (8 items, parent only).
COMPUTE ppbhaqatst1 = 8 * MEAN.4(ppbhaq081, ppbhaq091, ppbhaq10r1,
 ppbhaq11r1, ppbhaq121, ppbhaq13r1, ppbhaq14r1, ppbhaq15r1) .
EXECUTE .

* Imagination scale (6 items, parent only).
COMPUTE ppbhaqimat1 = 6 * MEAN.3(ppbhaq16r1, ppbhaq17r1, ppbhaq18r1,
 ppbhaq191, ppbhaq201, ppbhaq21r1) .
EXECUTE .

* Attention to Detail scale (5 items).
COMPUTE ppbhaqdett1 = 5 * MEAN.3(ppbhaq241, ppbhaq251, ppbhaq261, ppbhaq271, ppbhaq281) .
COMPUTE pcbhaqdett = 5 * MEAN.3(pcbhaq09, pcbhaq10, pcbhaq11, pcbhaq12, pcbhaq13) .
EXECUTE .

* Total scale (all items).
COMPUTE ppbhaqt1 = 28 * MEAN.14(ppbhaq01r1, ppbhaq02r1, ppbhaq031,
 ppbhaq04r1, ppbhaq051, ppbhaq06r1, ppbhaq07r1, ppbhaq081, ppbhaq091, ppbhaq10r1,
 ppbhaq11r1, ppbhaq121, ppbhaq13r1, ppbhaq14r1, ppbhaq15r1, ppbhaq16r1, ppbhaq17r1,
 ppbhaq18r1, ppbhaq191, ppbhaq201, ppbhaq21r1, ppbhaq22r1, ppbhaq231, ppbhaq241,
 ppbhaq251, ppbhaq261, ppbhaq271, ppbhaq281).
COMPUTE pcbhaqt = 13 * MEAN.7(pcbhaq01r, pcbhaq02r, pcbhaq03,
 pcbhaq04r, pcbhaq05, pcbhaq06r, pcbhaq07r, pcbhaq08, pcbhaq09,
 pcbhaq10, pcbhaq11, pcbhaq12, pcbhaq13).
EXECUTE.
pcbhcapst1/2, pcl2capst1/2

CAPS scale.
Total scale derived from all 9 items of the CAPS measure in the child behaviour/leap/leap-2 study booklet.
Variable pcbhcapst1/2 is from behaviour/leap, while pcl2capst1/2 is from leap-2.
Each item has integer values 0-5, hence the scale has range 0-45 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcbhcapst (or pcl2capst), which is later copied into variables pcbhcapst1/2 or (pcl2capst) on double entry.

* total scale (all 9 items).
COMPUTE pcbhcapst = 9 * MEAN.5(pcbhcaps1, pcbhcaps2, pcbhcaps3,
 pcbhcaps4, pcbhcaps5, pcbhcaps6, pcbhcaps7, pcbhcaps8, pcbhcaps9).
COMPUTE pcl2capst = 9 * MEAN.5(pcl2caps1, pcl2caps2, pcl2caps3,
 pcl2caps4, pcl2caps5, pcl2caps6, pcl2caps7, pcl2caps8, pcl2caps9).
EXECUTE.
pcbhcasit1/2, pcl2casit1/2

CASI Anxiety scale.
Total scale derived from all 18 items of the CASI Anxiety measure in the child behaviour/leap/leap-2 study booklet.
Variable pcbhcasit1/2 is from behaviour/leap, while pcl2casit1/2 is from leap-2.
Each item has integer values 0-2, hence the scale has range 0-36 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcbhcasit (or pcl2casit), which is later copied into variables pcbhcasit1/2 (or pcl2casit1/2) on double entry.

* Total scale (all 18 items).
COMPUTE pcbhcasit = 18 * MEAN.9(pcbhcasi01, pcbhcasi02, pcbhcasi03, pcbhcasi04,
 pcbhcasi05, pcbhcasi06, pcbhcasi07, pcbhcasi08, pcbhcasi09, pcbhcasi10,
 pcbhcasi11, pcbhcasi12, pcbhcasi13, pcbhcasi14, pcbhcasi15, pcbhcasi16,
 pcbhcasi17, pcbhcasi18).
COMPUTE pcl2casit = 18 * MEAN.9(pcl2casi01, pcl2casi02, pcl2casi03, pcl2casi04,
 pcl2casi05, pcl2casi06, pcl2casi07, pcl2casi08, pcl2casi09, pcl2casi10,
 pcl2casi11, pcl2casi12, pcl2casi13, pcl2casi14, pcl2casi15, pcl2casi16,
 pcl2casi17, pcl2casi18).
EXECUTE.
pcbhcgdst1/2, pcl2cgdst1/2

Cognitive Disorganisation scale.
Total scale derived from all 11 items of the Cognitive Disorganisation measure in the child behaviour/leap/leap-2 study booklet.
Variable pcbhcgdst1/2 is from behaviour/leap, while pcl2cgdst1/2 is from leap-2.
Each item has integer values 0 and 1, hence the scale has range 0-11 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcbhcgdst (or pcl2cgdst), which is later copied into variables pcbhcgdst1/2 (or pcl2cgdst1/2) on double entry.

* total scale (all 11 items).
COMPUTE pcbhcgdst = 11 * MEAN.6(pcbhcgds01, pcbhcgds02, pcbhcgds03,
 pcbhcgds04, pcbhcgds05, pcbhcgds06, pcbhcgds07, pcbhcgds08,
 pcbhcgds09, pcbhcgds10, pcbhcgds11).
COMPUTE pcl2cgdst = 11 * MEAN.6(pcl2cgds01, pcl2cgds02, pcl2cgds03,
 pcl2cgds04, pcl2cgds05, pcl2cgds06, pcl2cgds07, pcl2cgds08,
 pcl2cgds09, pcl2cgds10, pcl2cgds11).
EXECUTE.
pcbhdlnqt1/2

Delinquency scale.
This is essentially a count of the number of delinquent behaviours reported in the child behaviour study booklet (only included in wave 1). It is derived as the sum of the part (a) responses to all 8 questions; each such question is coded 1/0, hence the sum may have values 0-8. Note that items 7 and 8, having negligible numbers of responses, were dropped in the script after deriving this scale.

* Delinquency.
* Included in twin Behaviour booklet, cohort 1 only.
* No method of making a conventional scale has been proposed.
* Instead, derive a count of the delinquent behaviours.
* using the part (a) response for each of the 8 items.
COMPUTE pcbhdlnqt = SUM.4(pcbhdlnq1a, pcbhdlnq2a, pcbhdlnq3a, 
 pcbhdlnq4a, pcbhdlnq5a, pcbhdlnq6a, pcbhdlnq7a, pcbhdlnq8a).
EXECUTE.
pcbheddsm1/2

Eating Disorders scale.
Total scale derived from all 4 items of the Eating Disorders measure in the child behaviour study booklet (only included in wave 1).
Requires preliminary recoding into temporary variables, to remove "prefer not to answer" responses (these temporary variables are not retained in the dataset).
The recoded items have ordinal integer values 1-7, and the scale is a mean so it also has values in the range 1-7 but with decimal values.
The scale is computed as pcbheddsm in the syntax below, and later copied to variables pcbheddsm1/2 on double entry.

* Need to recode 8 (don't know) to missing in temporary variables.
* so can then work out the mean of four ordinal items.
RECODE pcbhedds1 pcbhedds2 pcbhedds3 pcbhedds4
 (8=SYSMIS)
INTO pcbhedds1x pcbhedds2x pcbhedds3x pcbhedds4x.
EXECUTE.
* Total scale (all 4 items).
COMPUTE pcbheddsm = MEAN.2(pcbhedds1x, pcbhedds2x, pcbhedds3x, pcbhedds4x).
EXECUTE.
pcbhgrndt1/2, pcl2grndt1/2

Grandiosity and Delusion scale.
Total scale derived from all 8 items of the Grandiosity and Delusion measure in the child behaviour/leap/leap-2 study booklet.
Variable pcbhgrndt1/2 is from behaviour/leap, while pcl2grndt1/2 is from leap-2.
Each item has integer values 0-3, hence the scale has range 0-24 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcbhgrndt (or pcl2grndt), which is later copied into variables pcbhgrndt1/2 (or pcl2grndt1/2) on double entry.

* total scale (all 8 items).
COMPUTE pcbhgrndt = 8 * MEAN.4(pcbhgrnd1, pcbhgrnd2, pcbhgrnd3,
 pcbhgrnd4, pcbhgrnd5, pcbhgrnd6, pcbhgrnd7, pcbhgrnd8).
COMPUTE pcl2grndt = 8 * MEAN.4(pcl2grnd1, pcl2grnd2, pcl2grnd3,
 pcl2grnd4, pcl2grnd5, pcl2grnd6, pcl2grnd7, pcl2grnd8).
EXECUTE.
pcbhicutcalt1/2, pcbhicutunct1/2, pcbhicutunet1/2, pcbhicutt1/2, ppbhicutcalt1/2, ppbhicutunct1/2, ppbhicutunet1/2, ppbhicutt1/2

ICUT (Inventory of Callous Unemotional Traits) scales.
Parent and child self-report versions: total scale and three subscales.
Derived from items (reversed where necessary) of the ICUT measure in the parent and child behaviour booklets.
Each item has integer values 0-3, hence each scale has a range of values from 0 to (3 * number of items) because it is computed as the mean multiplied by the number of component items.
In the syntax below, the child scales are computed as variables pcbhicutXXXt, which are later copied into variables pcbhicutXXXt1/2 on double entry.

* Callous scale (11 items).
COMPUTE pcbhicutcalt = 11 * MEAN.6(pcbhicut02, pcbhicut04, pcbhicut07,
 pcbhicut08r, pcbhicut09, pcbhicut10, pcbhicut11, pcbhicut12, 
 pcbhicut18, pcbhicut20, pcbhicut21) .
COMPUTE ppbhicutcalt1 = 11 * MEAN.6(ppbhicut021, ppbhicut041, ppbhicut071,
 ppbhicut08r1, ppbhicut09r1, ppbhicut101, ppbhicut111, ppbhicut121,
 ppbhicut181, ppbhicut201, ppbhicut211) .
EXECUTE .

* Unemotional scale (5 items).
COMPUTE pcbhicutunet = 5 * MEAN.3(pcbhicut01r, pcbhicut06,
 pcbhicut14r, pcbhicut19r, pcbhicut22).
COMPUTE ppbhicutunet1 = 5 * MEAN.3(ppbhicut01r1, ppbhicut061,
 ppbhicut14r1, ppbhicut19r1, ppbhicut221).
EXECUTE .

* Uncaring scale (8 items).
COMPUTE pcbhicutunct = 8 * MEAN.4(pcbhicut03r, pcbhicut05r,
 pcbhicut13r, pcbhicut15r, pcbhicut16r, pcbhicut17r, pcbhicut23r, pcbhicut24r).
COMPUTE ppbhicutunct1 = 8 * MEAN.4(ppbhicut03r1, ppbhicut05r1,
 ppbhicut13r1, ppbhicut15r1, ppbhicut16r1, ppbhicut17r1, ppbhicut23r1, ppbhicut24r1).
EXECUTE .

* Total scale (all 24 items).
COMPUTE pcbhicutt = 24 * MEAN.12(pcbhicut01r, pcbhicut02, pcbhicut03r,
 pcbhicut04, pcbhicut05r, pcbhicut06, pcbhicut07, pcbhicut08r, pcbhicut09,
 pcbhicut10, pcbhicut11, pcbhicut12, pcbhicut13r, pcbhicut14r, pcbhicut15r,
 pcbhicut16r, pcbhicut17r, pcbhicut18, pcbhicut19r, pcbhicut20, pcbhicut21,
 pcbhicut22, pcbhicut23r, pcbhicut24r).
COMPUTE ppbhicutt1 = 24 * MEAN.12(ppbhicut01r1, ppbhicut021, ppbhicut03r1,
 ppbhicut041, ppbhicut05r1, ppbhicut061, ppbhicut071, ppbhicut08r1,
 ppbhicut09r1, ppbhicut101, ppbhicut111, ppbhicut121, ppbhicut13r1,
 ppbhicut14r1, ppbhicut15r1, ppbhicut16r1, ppbhicut17r1, ppbhicut181,
 ppbhicut19r1, ppbhicut201, ppbhicut211, ppbhicut221, ppbhicut23r1, ppbhicut24r1).
EXECUTE .
pcbhinsomt1/2

Insomnia scale.
Total scale derived from all 7 items of the Insomnia Severity Index measure in the child behaviour/LEAP study booklet.
Items have integer values 0-4, hence the scale has total values in the range 0-28.
In the syntax below, the scale is computed as variable pcbhinsomt, which is later copied into variables pcbhinsomt1/2 on double entry.

* Recode items 5-7 into temporary variables with values 0-4.
* Both 'no sleep problem' and 'not at all' are coded as 0.
RECODE pcbhinsom5 pcbhinsom6 pcbhinsom7
 (0=0) (1=0) (2=1) (3=2) (4=3) (5=4)
INTO pcbhinsom5x pcbhinsom6x pcbhinsom7x.
EXECUTE.

* Total scale (all 7 items).
COMPUTE pcbhinsomt = 7 * MEAN.4(pcbhinsom1, pcbhinsom2, pcbhinsom3,
 pcbhinsom4, pcbhinsom5x, pcbhinsom6x, pcbhinsom7x).
EXECUTE.
pcbhlfevnat1/2, pcbhlfevnnt1/2, pcbhlfevpat1/2, pcbhlfevpnt1/2, pcl2lfevnat1/2, pcl2lfevnnt1/2, pcl2lfevpat1/2, pcl2lfevpnt1/2, ppbhlfevnat1/2, ppbhlfevnnt1/2, ppbhlfevpat1/2, ppbhlfevpnt1/2, ppl2lfevnat1/2, ppl2lfevnnt1/2, ppl2lfevpat1/2, ppl2lfevpnt1/2

Life Events composites. Note that these are not conventional scales derived as means, but are counts of events that occurred. Each event is categorised as having affected twins positively, negatively or both, according to the observed responses in the raw data.
Variable name prefixes (pcbh, pcl2, ppbh, ppl2) denote the rater and questionnaire in the usual way: pc=twin, pp=parent, bh=behaviour/leap-1, l2=leap-2. The same 20 events were presented in all four questionnaires, in the same order as items are numbered.
Variable name suffixes denote the type of count:
nat=count of events reported as having a negative effect;
nnt=count of events reported as having no effect although usually perceived as negative;
pat=count of events reported as having a positive effect;
pnt=count of events reported as having no effect although usually perceived as positive.
Note that some items elicited responses as having both negative and positive effects on the twins, so counts have been made for both. In these cases, most responses were positive, so where no effect was reported, this was included in the 'positive' count (pnt) but not in the 'negative' count (nnt), to avoid counting the same event twice in different variables. Full details of the derivation can be found in comments in the syntax below.

* Life Events.
* Parent and twin, both Behaviour/Leap and Leap-2.
* Derive counts of positive and negative events as at age 26.
* separate counts being made according to whether or not events had a perceived effect.
* First, make a temporary count of all valid responses, positive and negative separately.
* noting that these will have value 0 by default even if all items are missing.
* Note also that in parent leap-2, some responses were elicited just once for the twin pair.
* and these will be added to the count for both of the twins.
COUNT pcbhlfevncount = pcbhlfev01n pcbhlfev02n pcbhlfev03n pcbhlfev04n pcbhlfev05n 
  pcbhlfev06n pcbhlfev07n pcbhlfev08n pcbhlfev09n pcbhlfev10n pcbhlfev11n pcbhlfev12n 
  pcbhlfev13n pcbhlfev14n pcbhlfev15n pcbhlfev16n pcbhlfev17n pcbhlfev19n pcbhlfev20n 
  (0 THRU HIGHEST). 
COUNT pcl2lfevncount = pcl2lfev01n pcl2lfev02n pcl2lfev03n pcl2lfev04n pcl2lfev05n 
  pcl2lfev06n pcl2lfev07n pcl2lfev08n pcl2lfev09n pcl2lfev10n pcl2lfev11n pcl2lfev12n 
  pcl2lfev13n pcl2lfev14n pcl2lfev15n pcl2lfev16n pcl2lfev17n pcl2lfev19n pcl2lfev20n 
  (0 THRU HIGHEST).
COUNT ppbhlfevncount1 = ppbhlfev01n1 ppbhlfev02n1 ppbhlfev03n1 ppbhlfev04n1 ppbhlfev05n1 
  ppbhlfev06n1 ppbhlfev07n1 ppbhlfev08n1 ppbhlfev09n1 ppbhlfev10n1 ppbhlfev11n1 
  ppbhlfev12n1 ppbhlfev13n1 ppbhlfev14n1 ppbhlfev15n1 ppbhlfev16n1 ppbhlfev17n1 
  ppbhlfev19n1 ppbhlfev20n1 (0 THRU HIGHEST).
COUNT ppbhlfevncount2 = ppbhlfev01n2 ppbhlfev02n2 ppbhlfev03n2 ppbhlfev04n2 ppbhlfev05n2 
  ppbhlfev06n2 ppbhlfev07n2 ppbhlfev08n2 ppbhlfev09n2 ppbhlfev10n2 ppbhlfev11n2 
  ppbhlfev12n2 ppbhlfev13n2 ppbhlfev14n2 ppbhlfev15n2 ppbhlfev16n2 ppbhlfev17n2 
  ppbhlfev19n2 ppbhlfev20n2 (0 THRU HIGHEST).
COUNT ppl2lfevncount1 = ppl2lfev01n ppl2lfev02n ppl2lfev03n1 ppl2lfev04n1 ppl2lfev05n1 
  ppl2lfev06n1 ppl2lfev07n1 ppl2lfev08n ppl2lfev09n1 ppl2lfev10n1 ppl2lfev11n 
  ppl2lfev12n ppl2lfev13n1 ppl2lfev14n ppl2lfev15n1 ppl2lfev16n1 ppl2lfev17n 
  ppl2lfev19n1 ppl2lfev20n1 (0 THRU HIGHEST).
COUNT ppl2lfevncount2 = ppl2lfev01n ppl2lfev02n ppl2lfev03n2 ppl2lfev04n2 ppl2lfev05n2 
  ppl2lfev06n2 ppl2lfev07n2 ppl2lfev08n ppl2lfev09n2 ppl2lfev10n2 ppl2lfev11n 
  ppl2lfev12n ppl2lfev13n2 ppl2lfev14n ppl2lfev15n2 ppl2lfev16n2 ppl2lfev17n 
  ppl2lfev19n2 ppl2lfev20n2 (0 THRU HIGHEST).
COUNT pcbhlfevpcount = pcbhlfev03p pcbhlfev06p pcbhlfev07p pcbhlfev11p 
  pcbhlfev16p pcbhlfev17p pcbhlfev18p pcbhlfev19p pcbhlfev20p (0 THRU HIGHEST).
COUNT pcl2lfevpcount = pcl2lfev03p pcl2lfev06p pcl2lfev07p pcl2lfev11p 
  pcl2lfev16p pcl2lfev17p pcl2lfev18p pcl2lfev19p pcl2lfev20p (0 THRU HIGHEST).
COUNT ppbhlfevpcount1 = ppbhlfev06p1 ppbhlfev11p1 ppbhlfev16p1 ppbhlfev17p1 
  ppbhlfev18p1 ppbhlfev19p1 ppbhlfev20p1 (0 THRU HIGHEST).
COUNT ppbhlfevpcount2 = ppbhlfev06p2 ppbhlfev11p2 ppbhlfev16p2 ppbhlfev17p2 
  ppbhlfev18p2 ppbhlfev19p2 ppbhlfev20p2 (0 THRU HIGHEST). 
COUNT ppl2lfevpcount1 = ppl2lfev06p1 ppl2lfev11p ppl2lfev16p1 ppl2lfev17p 
  ppl2lfev18p1 ppl2lfev19p1 ppl2lfev20p1 (0 THRU HIGHEST).
COUNT ppl2lfevpcount2 = ppl2lfev06p2 ppl2lfev11p ppl2lfev16p2 ppl2lfev17p 
  ppl2lfev18p2 ppl2lfev19p2 ppl2lfev20p2 (0 THRU HIGHEST).
EXECUTE.
* Counts of events that occurred may be invalid if too many items are missing.
* so require over half of the respective items to be non-missing below.
* Note that items 6, 11, 16, 17, 19 and 20 (all ratings) and items 3, 7 (for twins not parents).
*   have elicited responses as both positive and negative events.
*   In these cases, to avoid counting responses twice, which may only occur if response is.
*   'yes but did not affect me' (value 1), only count this response for the.
*   'positive' category because this is the more common type of response in all these items.
DO IF (pcbhlfevncount >= 10).
* negative life events that affected the twin (coded 2 or 3).
 COUNT pcbhlfevnat = pcbhlfev01n pcbhlfev02n pcbhlfev03n pcbhlfev04n pcbhlfev05n 
  pcbhlfev06n pcbhlfev07n pcbhlfev08n pcbhlfev09n pcbhlfev10n pcbhlfev11n pcbhlfev12n 
  pcbhlfev13n pcbhlfev14n pcbhlfev15n pcbhlfev16n pcbhlfev17n pcbhlfev19n pcbhlfev20n (2, 3).
* negative life events that reportedly did not affect the twin (coded 1).
* (note this count does not include those events that are also coded as positive).
 COUNT pcbhlfevnnt = pcbhlfev01n pcbhlfev02n pcbhlfev04n pcbhlfev05n 
  pcbhlfev08n pcbhlfev09n pcbhlfev10n pcbhlfev12n pcbhlfev13n pcbhlfev14n pcbhlfev15n (1).
END IF.
DO IF (pcbhlfevpcount >= 5).
* positive life events that affected the twin (coded 2 or 3).
 COUNT pcbhlfevpat = pcbhlfev03p pcbhlfev06p pcbhlfev07p pcbhlfev11p 
  pcbhlfev16p pcbhlfev17p pcbhlfev18p pcbhlfev19p pcbhlfev20p (2, 3).
* positive events that did not affect the twin.
 COUNT pcbhlfevpnt = pcbhlfev03p pcbhlfev06p pcbhlfev07p pcbhlfev11p 
  pcbhlfev16p pcbhlfev17p pcbhlfev18p pcbhlfev19p pcbhlfev20p (1).
END IF.
EXECUTE.
DO IF (pcl2lfevncount >= 10).
* negative life events that affected the twin (coded 2 or 3).
 COUNT pcl2lfevnat = pcl2lfev01n pcl2lfev02n pcl2lfev03n pcl2lfev04n pcl2lfev05n 
  pcl2lfev06n pcl2lfev07n pcl2lfev08n pcl2lfev09n pcl2lfev10n pcl2lfev11n pcl2lfev12n 
  pcl2lfev13n pcl2lfev14n pcl2lfev15n pcl2lfev16n pcl2lfev17n pcl2lfev19n pcl2lfev20n (2, 3).
* negative life events that reportedly did not affect the twin (coded 1).
* (note this count excludes events that are also coded as positive).
 COUNT pcl2lfevnnt = pcl2lfev01n pcl2lfev02n pcl2lfev04n pcl2lfev05n 
  pcl2lfev08n pcl2lfev09n pcl2lfev10n pcl2lfev12n pcl2lfev13n pcl2lfev14n pcl2lfev15n (1).
END IF.
DO IF (pcl2lfevpcount >= 5).
* positive life events that affected the twin (coded 2 or 3).
 COUNT pcl2lfevpat = pcl2lfev03p pcl2lfev06p pcl2lfev07p pcl2lfev11p 
  pcl2lfev16p pcl2lfev17p pcl2lfev18p pcl2lfev19p pcl2lfev20p (2, 3).
* positive events that did not affect the twin.
 COUNT pcl2lfevpnt = pcl2lfev03p pcl2lfev06p pcl2lfev07p pcl2lfev11p 
  pcl2lfev16p pcl2lfev17p pcl2lfev18p pcl2lfev19p pcl2lfev20p (1).
END IF.
EXECUTE.
* Repeat for ppbh (there are variables for each twin).
DO IF (ppbhlfevncount1 >= 10).
 COUNT ppbhlfevnat1 = ppbhlfev01n1 ppbhlfev02n1 ppbhlfev03n1 ppbhlfev04n1 ppbhlfev05n1 
  ppbhlfev06n1 ppbhlfev07n1 ppbhlfev08n1 ppbhlfev09n1 ppbhlfev10n1 ppbhlfev11n1 ppbhlfev12n1
  ppbhlfev13n1 ppbhlfev14n1 ppbhlfev15n1 ppbhlfev16n1 ppbhlfev17n1 ppbhlfev19n1 ppbhlfev20n1 (2, 3).
 COUNT ppbhlfevnnt1 = ppbhlfev01n1 ppbhlfev02n1 ppbhlfev03n1 ppbhlfev04n1 ppbhlfev05n1 
  ppbhlfev07n1 ppbhlfev08n1 ppbhlfev09n1 ppbhlfev10n1 ppbhlfev12n1
  ppbhlfev13n1 ppbhlfev14n1 ppbhlfev15n1 (1).
END IF.
DO IF (ppbhlfevncount2 >= 10).
 COUNT ppbhlfevnat2 = ppbhlfev01n2 ppbhlfev02n2 ppbhlfev03n2 ppbhlfev04n2 ppbhlfev05n2 
  ppbhlfev06n2  ppbhlfev07n2 ppbhlfev08n2 ppbhlfev09n2 ppbhlfev10n2 ppbhlfev11n2 ppbhlfev12n2 
  ppbhlfev13n2 ppbhlfev14n2 ppbhlfev15n2 ppbhlfev16n2 ppbhlfev17n2 ppbhlfev19n2 ppbhlfev20n2 (2, 3).
 COUNT ppbhlfevnnt2 = ppbhlfev01n2 ppbhlfev02n2 ppbhlfev03n2 ppbhlfev04n2 ppbhlfev05n2 
  ppbhlfev07n2 ppbhlfev08n2 ppbhlfev09n2 ppbhlfev10n2 ppbhlfev12n2 
  ppbhlfev13n2 ppbhlfev14n2 ppbhlfev15n2 (1).
END IF.
DO IF (ppbhlfevpcount1 >= 5).
 COUNT ppbhlfevpat1 = ppbhlfev06p1 ppbhlfev11p1 ppbhlfev16p1 ppbhlfev17p1 
  ppbhlfev18p1 ppbhlfev19p1 ppbhlfev20p1 (2, 3).
 COUNT ppbhlfevpnt1 = ppbhlfev06p1 ppbhlfev11p1 ppbhlfev16p1 ppbhlfev17p1 
  ppbhlfev18p1 ppbhlfev19p1 ppbhlfev20p1 (1).
END IF.
DO IF (ppbhlfevpcount2 >= 5).
 COUNT ppbhlfevpat2 = ppbhlfev06p2 ppbhlfev11p2 ppbhlfev16p2 ppbhlfev17p2 
  ppbhlfev18p2 ppbhlfev19p2 ppbhlfev20p2 (2, 3).
 COUNT ppbhlfevpnt2 = ppbhlfev06p2 ppbhlfev11p2 ppbhlfev16p2 ppbhlfev17p2 
  ppbhlfev18p2 ppbhlfev19p2 ppbhlfev20p2 (1).
END IF.
EXECUTE.
* Repeat for ppl2 (variables for each twin for most events.
*  and where there is one variable per twin pair, count this for both twins).
DO IF (ppl2lfevncount1 >= 10).
 COUNT ppl2lfevnat1 = ppl2lfev01n ppl2lfev02n ppl2lfev03n1 ppl2lfev04n1 ppl2lfev05n1 ppl2lfev06n1 
  ppl2lfev07n1 ppl2lfev08n ppl2lfev09n1 ppl2lfev10n1 ppl2lfev11n ppl2lfev12n 
  ppl2lfev13n1 ppl2lfev14n ppl2lfev15n1 ppl2lfev16n1 ppl2lfev17n ppl2lfev19n1 ppl2lfev20n1 (2, 3).
 COUNT ppl2lfevnnt1 = ppl2lfev01n ppl2lfev02n ppl2lfev03n1 ppl2lfev04n1 ppl2lfev05n1  
  ppl2lfev07n1 ppl2lfev08n ppl2lfev09n1 ppl2lfev10n1 ppl2lfev12n 
  ppl2lfev13n1 ppl2lfev14n ppl2lfev15n1 (1).
END IF.
DO IF (ppl2lfevncount2 >= 10).
 COUNT ppl2lfevnat2 = ppl2lfev01n ppl2lfev02n ppl2lfev03n2 ppl2lfev04n2 ppl2lfev05n2 ppl2lfev06n2 
  ppl2lfev07n2 ppl2lfev08n ppl2lfev09n2 ppl2lfev10n2 ppl2lfev11n ppl2lfev12n 
  ppl2lfev13n2 ppl2lfev14n ppl2lfev15n2 ppl2lfev16n2 ppl2lfev17n ppl2lfev19n2 ppl2lfev20n2 (2, 3).
 COUNT ppl2lfevnnt2 = ppl2lfev01n ppl2lfev02n ppl2lfev03n2 ppl2lfev04n2 ppl2lfev05n2 
  ppl2lfev07n2 ppl2lfev08n ppl2lfev09n2 ppl2lfev10n2 ppl2lfev12n 
  ppl2lfev13n2 ppl2lfev14n ppl2lfev15n2 (1).
END IF.
DO IF (ppl2lfevpcount1 >= 5).
 COUNT ppl2lfevpat1 = ppl2lfev06p1 ppbhlfev11p1 ppl2lfev16p1 ppl2lfev17p ppl2lfev18p1 
  ppl2lfev19p1 ppl2lfev20p1 (2, 3).
 COUNT ppl2lfevpnt1 = ppl2lfev06p1 ppbhlfev11p1 ppl2lfev16p1 ppl2lfev17p ppl2lfev18p1 
  ppl2lfev19p1 ppl2lfev20p1 (1).
END IF.
DO IF (ppl2lfevpcount2 >= 5).
 COUNT ppl2lfevpat2 = ppl2lfev06p2 ppbhlfev11p2 ppl2lfev16p2 ppl2lfev17p ppl2lfev18p2 
  ppl2lfev19p2 ppl2lfev20p2 (2, 3).
 COUNT ppl2lfevpnt2 = ppl2lfev06p2 ppbhlfev11p2 ppl2lfev16p2 ppl2lfev17p ppl2lfev18p2 
  ppl2lfev19p2 ppl2lfev20p2 (1).
END IF.
EXECUTE.
* These counts all fizzle out at the high end.
* so recode into categories for higher count values.
* 5+ for counts of negative events that affected twins.
* 4+ for counts of positive events that affected twins.
* 3+ for positive/negative events that did not affect twins.
RECODE pcbhlfevnat pcl2lfevnat ppbhlfevnat1 ppbhlfevnat2 ppl2lfevnat1 ppl2lfevnat2 
 (5 THRU HIGHEST=5) (ELSE=COPY).
RECODE pcbhlfevpat pcl2lfevpat ppbhlfevpat1 ppbhlfevpat2 ppl2lfevpat1 ppl2lfevpat2 
 (4 THRU HIGHEST=4) (ELSE=COPY).
RECODE pcbhlfevnnt pcbhlfevpnt pcl2lfevnnt pcl2lfevpnt 
 ppbhlfevnnt1 ppbhlfevpnt1 ppbhlfevnnt2 ppbhlfevpnt2
 ppl2lfevnnt1 ppl2lfevpnt1 ppl2lfevnnt2 ppl2lfevpnt2
 (3 THRU HIGHEST=3) (ELSE=COPY).
EXECUTE.
pcbhLLCage1/2, pcbhLLCdate1/2, pcexgcseLLCage, pcexgcseLLCdate, pcexLLCage1/2, pcexLLCdate1/2, pcl2LLCage1/2, pcl2LLCdate1/2, pcwebLLCage1/2, pcwebLLCdate1/2, ppbhLLCage, ppbhLLCdate, ppl2LLCage, ppl2LLCdate

Age and date variables derived for use in datasets in the LLC TRE (but not to be used in other datasets).
Ages and dates are derived for the parent behaviour/leap booklet ('ppbh'), the child behaviour/leap booklet ('pcbh'), the parent leap-2 booklet ('ppl2'), the child leap-2 booklet ('pcl2'), the child web activities ('pcweb'), return of the child exam results questionnaire ('pcex'), and estimates for when GCSE exams were actually taken ('pcexgcse').
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 activity dates.
COMPUTE birthyear = XDATE.YEAR(aonsdob).
COMPUTE birthmonth = XDATE.MONTH(aonsdob).
COMPUTE pcwebyear1 = XDATE.YEAR(pcwebstdt1).
COMPUTE pcwebmonth1 = XDATE.MONTH(pcwebstdt1).
COMPUTE pcwebyear2 = XDATE.YEAR(pcwebstdt2).
COMPUTE pcwebmonth2 = XDATE.MONTH(pcwebstdt2).
COMPUTE ppbhyear = XDATE.YEAR(ppbhrdate).
COMPUTE ppbhmonth = XDATE.MONTH(ppbhrdate).
COMPUTE pcbhyear1 = XDATE.YEAR(pcbhrdate1).
COMPUTE pcbhmonth1 = XDATE.MONTH(pcbhrdate1).
COMPUTE pcbhyear2 = XDATE.YEAR(pcbhrdate2).
COMPUTE pcbhmonth2 = XDATE.MONTH(pcbhrdate2).
COMPUTE ppl2year = XDATE.YEAR(ppl2rdate).
COMPUTE ppl2month = XDATE.MONTH(ppl2rdate).
COMPUTE pcl2year1 = XDATE.YEAR(pcl2rdate1).
COMPUTE pcl2month1 = XDATE.MONTH(pcl2rdate1).
COMPUTE pcl2year2 = XDATE.YEAR(pcl2rdate2).
COMPUTE pcl2month2 = XDATE.MONTH(pcl2rdate2).
COMPUTE pcexyear1 = XDATE.YEAR(pcexrdate1).
COMPUTE pcexmonth1 = XDATE.MONTH(pcexrdate1).
COMPUTE pcexyear2 = XDATE.YEAR(pcexrdate2).
COMPUTE pcexmonth2 = XDATE.MONTH(pcexrdate2).
EXECUTE.

* The agreed LLC date format is a string yyyy-mm (nominal by default for strings).
* adding '0' where necessary for two-digit months.
STRING pcwebLLCdate1 pcwebLLCdate2 ppbhLLCdate pcbhLLCdate1 pcbhLLCdate2
 ppl2LLCdate pcl2LLCdate1 pcl2LLCdate2 pcexLLCdate1 pcexLLCdate2 pcexgcseLLCdate (A7).
IF (pcwebmonth1 < 10) pcwebLLCdate1 = CONCAT(STRING(pcwebyear1, F4), '-0', STRING(pcwebmonth1, F1)).
IF (pcwebmonth1 >= 10) pcwebLLCdate1 = CONCAT(STRING(pcwebyear1, F4), '-', STRING(pcwebmonth1, F2)).
IF (pcwebmonth2 < 10) pcwebLLCdate2 = CONCAT(STRING(pcwebyear2, F4), '-0', STRING(pcwebmonth2, F1)).
IF (pcwebmonth2 >= 10) pcwebLLCdate2 = CONCAT(STRING(pcwebyear2, F4), '-', STRING(pcwebmonth2, F2)).
IF (ppbhmonth < 10) ppbhLLCdate = CONCAT(STRING(ppbhyear, F4), '-0', STRING(ppbhmonth, F1)).
IF (ppbhmonth >= 10) ppbhLLCdate = CONCAT(STRING(ppbhyear, F4), '-', STRING(ppbhmonth, F2)).
IF (pcbhmonth1 < 10) pcbhLLCdate1 = CONCAT(STRING(pcbhyear1, F4), '-0', STRING(pcbhmonth1, F1)).
IF (pcbhmonth1 >= 10) pcbhLLCdate1 = CONCAT(STRING(pcbhyear1, F4), '-', STRING(pcbhmonth1, F2)).
IF (pcbhmonth2 < 10) pcbhLLCdate2 = CONCAT(STRING(pcbhyear2, F4), '-0', STRING(pcbhmonth2, F1)).
IF (pcbhmonth2 >= 10) pcbhLLCdate2 = CONCAT(STRING(pcbhyear2, F4), '-', STRING(pcbhmonth2, F2)).
IF (ppl2month < 10) ppl2LLCdate = CONCAT(STRING(ppl2year, F4), '-0', STRING(ppl2month, F1)).
IF (ppl2month >= 10) ppl2LLCdate = CONCAT(STRING(ppl2year, F4), '-', STRING(ppl2month, F2)).
IF (pcl2month1 < 10) pcl2LLCdate1 = CONCAT(STRING(pcl2year1, F4), '-0', STRING(pcl2month1, F1)).
IF (pcl2month1 >= 10) pcl2LLCdate1 = CONCAT(STRING(pcl2year1, F4), '-', STRING(pcl2month1, F2)).
IF (pcl2month2 < 10) pcl2LLCdate2 = CONCAT(STRING(pcl2year2, F4), '-0', STRING(pcl2month2, F1)).
IF (pcl2month2 >= 10) pcl2LLCdate2 = CONCAT(STRING(pcl2year2, F4), '-', STRING(pcl2month2, F2)).
IF (pcexmonth1 < 10) pcexLLCdate1 = CONCAT(STRING(pcexyear1, F4), '-0', STRING(pcexmonth1, F1)).
IF (pcexmonth1 >= 10) pcexLLCdate1 = CONCAT(STRING(pcexyear1, F4), '-', STRING(pcexmonth1, F2)).
IF (pcexmonth2 < 10) pcexLLCdate2 = CONCAT(STRING(pcexyear2, F4), '-0', STRING(pcexmonth2, F1)).
IF (pcexmonth2 >= 10) pcexLLCdate2 = CONCAT(STRING(pcexyear2, F4), '-', STRING(pcexmonth2, F2)).
EXECUTE.

* The agreed LLC 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 pcwebLLCage1 = (pcwebmonth1 + (pcwebyear1 * 12)) - (birthmonth + (birthyear * 12)).
COMPUTE pcwebLLCage2 = (pcwebmonth2 + (pcwebyear2 * 12)) - (birthmonth + (birthyear * 12)).
COMPUTE ppbhLLCage = (ppbhmonth + (ppbhyear * 12)) - (birthmonth + (birthyear * 12)).
COMPUTE pcbhLLCage1 = (pcbhmonth1 + (pcbhyear1 * 12)) - (birthmonth + (birthyear * 12)).
COMPUTE pcbhLLCage2 = (pcbhmonth2 + (pcbhyear2 * 12)) - (birthmonth + (birthyear * 12)).
COMPUTE ppl2LLCage = (ppl2month + (ppl2year * 12)) - (birthmonth + (birthyear * 12)).
COMPUTE pcl2LLCage1 = (pcl2month1 + (pcl2year1 * 12)) - (birthmonth + (birthyear * 12)).
COMPUTE pcl2LLCage2 = (pcl2month2 + (pcl2year2 * 12)) - (birthmonth + (birthyear * 12)).
COMPUTE pcexLLCage1 = (pcexmonth1 + (pcexyear1 * 12)) - (birthmonth + (birthyear * 12)).
COMPUTE pcexLLCage2 = (pcexmonth2 + (pcexyear2 * 12)) - (birthmonth + (birthyear * 12)).
EXECUTE.

* Estimate age and date when twin GCSE exams were taken.
* In the absence of a measured date, this is based on an assumption.
* (good in most cases) that all twins took GCSEs in June.
* at the end of the academic year in which they reached the age of 16 years.
* which is obtained by adding 2009 to the cohort number (1 to 4).
* The LLC version of the age is an integer number of months.
IF (pcexdata = 1) pcexgcseLLCage = (6 + ((2009 + cohort) * 12)) - (birthmonth + (birthyear * 12)).
* The LLC date is inferred (or guessed) based purely on the cohort.
IF (pcexdata = 1) pcexgcseLLCdate = CONCAT(STRING((2009 + cohort), F4), '-06').
EXECUTE.
pcbhlssm1/2

Life Satisfaction scale.
Total scale derived from all 6 items of the Life Satisfaction measure in the child behaviour study booklet.
Items have integer values 1-7, and the scale is a mean so it has the same range but with decimal values.
In the syntax below, the scale is computed as variable pcbhlssm, which is later copied into variables pcbhlssm1/2 on double entry.

* Total scale (all 6 items).
COMPUTE pcbhlssm = MEAN.3(pcbhlss1, pcbhlss2, pcbhlss3, pcbhlss4, pcbhlss5, pcbhlss6).
EXECUTE.
pcbhmaast1/2

Mindful Attention Awareness Scale (MAAS): total scale from all 5 items that were included in the twin behaviour booklet (cohort 1 only). Each item has integer values 0-5, hence this scale has a range of values from 0 to 25 because it is computed as the mean multiplied by the number of component items.

* MAAS.
* Included in twin Behaviour booklet, cohort 1 only.
* total scale: all 5 items.
COMPUTE pcbhmaast = 5 * MEAN.3(pcbhmaas1, pcbhmaas2, pcbhmaas3, pcbhmaas4, pcbhmaas5).
EXECUTE.
pcbhmfqt1/2, ppbhmfqt1/2, pcl2mfqt1/2, ppl2mfqt1/2

MFQ scales.
Parent and child self-report versions of a total scale.
Derived from all available items of the MFQ measure in the parent and child behaviour/leap/leap-2 booklets.
In each variable name, the second letter denotes the respondent (c=child, p=parent) and the third and fourth letters denotes the source (bh=behaviour/leap, l2=leap-2).
Note that the parent and child booklet measures included different subsets of the MFQ items, hence the parent and child scales include different numbers of items.
Each item has integer values 0-2, hence each scale has a range of values from 0 to (2 * number of items) because it is computed as the mean multiplied by the number of component items.
In the syntax below, the child scale is computed as variable pcbhmfqt (or pcl2mfqt), which is later copied into variables pcbhmfqt1/2 (or pcl2mfqt1/2) on double entry.

COMPUTE pcbhmfqt = 13 * MEAN.7(pcbhmfq01, pcbhmfq02, pcbhmfq03,
 pcbhmfq04, pcbhmfq05, pcbhmfq06, pcbhmfq07, pcbhmfq08, pcbhmfq09,
 pcbhmfq10, pcbhmfq11, pcbhmfq12, pcbhmfq13).
COMPUTE pcl2mfqt = 13 * MEAN.7(pcl2mfq01, pcl2mfq02, pcl2mfq03,
 pcl2mfq04, pcl2mfq05, pcl2mfq06, pcl2mfq07, pcl2mfq08, pcl2mfq09,
 pcl2mfq10, pcl2mfq11, pcl2mfq12, pcl2mfq13).
COMPUTE ppbhmfqt1 = 11 * MEAN.6(ppbhmfq011, ppbhmfq021, ppbhmfq031,
 ppbhmfq041, ppbhmfq051, ppbhmfq061, ppbhmfq071, ppbhmfq081,
 ppbhmfq091, ppbhmfq101, ppbhmfq111).
COMPUTE ppl2mfqt1 = 11 * MEAN.6(ppl2mfq011, ppl2mfq021, ppl2mfq031,
 ppl2mfq041, ppl2mfq051, ppl2mfq061, ppl2mfq071, ppl2mfq081,
 ppl2mfq091, ppl2mfq101, ppl2mfq111).
EXECUTE.
pcbhmlifem1/2

Meaning in Life scale.
Total scale derived from all 5 items of the Meaning in Life measure in the child Leap-2 study booklet (cohorts 2/3/4 only, not cohort 1).
Items have integer values 1-7, and the scale is a mean so it has the same range but with decimal values.

* Meaning in life.
* Included in the twin Leap booklet (not cohort 1).

* total (mean) scale, all 5 items.
COMPUTE pcbhmlifem = MEAN.3(pcbhmlife1, pcbhmlife2, pcbhmlife3, pcbhmlife4, pcbhmlife5).
EXECUTE.
pcbhmvaluem1/2, pcbhmvaluesucm1/2, pcbhmvaluecenm1/2, pcbhmvaluehapm1/2

Materialistic Values total scale and subscales, derived from the 6 items of the Materialistic Values measure in the child Leap-2 study booklet (cohorts 2/3/4 only, not cohort 1).
pcbhmvaluem1/2: overall total scale derived from all 6 items.
pcbhmvaluesucm1/2: success subscale from 2 items.
pcbhmvaluecenm1/2: centrality subscale from 2 items.
pcbhmvaluehapm1/2: happiness subscale from 2 items.
Items have integer values 1-5, and each scale is a mean so it has the same range but with decimal values.

* Materialistic values.
* Included in the twin Leap booklet (not cohort 1).

* Three subscales of 2 items each.
* Success subscale.
COMPUTE pcbhmvaluesucm = MEAN.1(pcbhmvalue1, pcbhmvalue2).
* Centrality subscale.
COMPUTE pcbhmvaluecenm = MEAN.1(pcbhmvalue3, pcbhmvalue4).
* Happiness subscale.
COMPUTE pcbhmvaluehapm = MEAN.1(pcbhmvalue5, pcbhmvalue6).
EXECUTE.

* total (mean) scale, all 6 items.
COMPUTE pcbhmvaluem = MEAN.3(pcbhmvalue1, pcbhmvalue2, 
    pcbhmvalue3, pcbhmvalue4, pcbhmvalue5, pcbhmvalue6).
EXECUTE.
pcbhpneedt1/2, pcbhpneedautt1/2, pcbhpneedcomt1/2, pcbhpneedrelt1/2

Psychological Needs total scale and subscales, derived from the 21 items (some reversed) of the Basic Psychological Needs measure in the child leap-2 booklet (cohorts 2/3/4 only, not cohort 1).
pcbhpneedt1/2: overall total scale from all 21 items.
pcbhpneedautt1/2: autonomy subscale from 7 items.
pcbhpneedcomt1/2: competence subscale from 6 items.
pcbhpneedrelt1/2: relatedness subscale from 8 items.
Items have integer values 0 to 6. Each scale is derived as a mean scaled up as if it were a total, hence each scale has decimal values ranging from 0 up to six times the number of items.

* Basic psychological needs.
* Included in the twin Leap booklet (not cohort 1).

* 3 published subscales.
* Autonomy: 7 items.
COMPUTE pcbhpneedautt = 7 * MEAN.4(pcbhpneed01, pcbhpneed04r, 
  pcbhpneed08, pcbhpneed11r, pcbhpneed14, pcbhpneed17, pcbhpneed20r).
* Competence: 6 items.
COMPUTE pcbhpneedcomt = 6 * MEAN.3(pcbhpneed03r, pcbhpneed05, 
  pcbhpneed10, pcbhpneed13, pcbhpneed15r, pcbhpneed19r).
* Relatedness: 8 items.
COMPUTE pcbhpneedrelt = 8 * MEAN.4(pcbhpneed02, pcbhpneed06, pcbhpneed07r, 
  pcbhpneed09, pcbhpneed12, pcbhpneed16r, pcbhpneed18r, pcbhpneed21).
EXECUTE.

* total scale: all 21 items.
* some items are reversed so that higher values indicate more positive wellbeing.
COMPUTE pcbhpneedt = 21 * MEAN.11(pcbhpneed01, pcbhpneed02, pcbhpneed03r, 
    pcbhpneed04r, pcbhpneed05, pcbhpneed06, pcbhpneed07r, pcbhpneed08, pcbhpneed09, 
    pcbhpneed10, pcbhpneed11r, pcbhpneed12, pcbhpneed13, pcbhpneed14, pcbhpneed15r, 
    pcbhpneed16r, pcbhpneed17, pcbhpneed18r, pcbhpneed19r, pcbhpneed20r, pcbhpneed21).
EXECUTE.
pcbhprndt1/2, pcl2prndt1/2

Paranoid Checklist scale.
Total scale derived from all 15 items of the Paranoid Checklist measure in the child behaviour/leap/leap-2 study booklet.
Variable pcbhprndt1/2 is from behaviour/leap, while pcl2prndt1/2 is from leap-2.
Each item has integer values 0-5, hence the scale has range 0-75 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcbhprndt (or pcl2prndt), which is later copied into variables pcbhprndt1/2 (or pcl2prndt1/2) on double entry.

* total scale (all 15 items).
COMPUTE pcbhprndt = 15 * MEAN.8(pcbhprnd01, pcbhprnd02, pcbhprnd03,
 pcbhprnd04, pcbhprnd05, pcbhprnd06, pcbhprnd07, pcbhprnd08, pcbhprnd09,
 pcbhprnd10, pcbhprnd11, pcbhprnd12, pcbhprnd13, pcbhprnd14, pcbhprnd15).
COMPUTE pcl2prndt = 15 * MEAN.8(pcl2prnd01, pcl2prnd02, pcl2prnd03,
 pcl2prnd04, pcl2prnd05, pcl2prnd06, pcl2prnd07, pcl2prnd08, pcl2prnd09,
 pcl2prnd10, pcl2prnd11, pcl2prnd12, pcl2prnd13, pcl2prnd14, pcl2prnd15).
EXECUTE.
pcbhsdqbeht1/2, pcbhsdqemot1/2, pcbhsdqcont1/2, pcbhsdqhypt1/2, pcbhsdqpert1/2, pcbhsdqprot1/2, ppbhsdqbeht1/2, ppbhsdqcont1/2, ppbhsdqhypt1/2, ppbhsdqprot1/2, ppl2sdqbeht1/2, ppl2sdqcont1/2, ppl2sdqhypt1/2, ppl2sdqprot1/2

SDQ scales.
Parent and child self-report versions: total behaviour problems scale plus five subscales.
Derived from items (reversed where necessary) of the SDQ measure in the parent and child behaviour/leap/leap-2 booklets.
Behaviour/leap scales have names starting with pcbh (child) and ppbh (parent), while leap-2 scales have names starting with ppl2 (parent only).
Note that the parent and child measures included different subsets of the SDQ items, hence there are differences between the parent and child scales and subscales.
Note also that the child Emotion subscale uses an MFQ items in addition to four SDQ items.
Note also that the SDQ measure was dropped from the child leap-2 booklet.
Each item has integer values 0-2, hence each scale has a range of values from 0 to (2 * number of items) because it is computed as the mean multiplied by the number of component items.

* Emotion scale (previously called Anxiety, child only).
* 5 items including one MFQ.
COMPUTE pcbhsdqemot = 5 * MEAN.3(pcbhmfq01, pcbhsdqemo1, pcbhsdqemo2, pcbhsdqemo4, pcbhsdqemo5) .
EXECUTE.

* Peer problems scale (5 items, child only).
COMPUTE pcbhsdqpert = 5 * MEAN.3(pcbhsdqper1, pcbhsdqper2r,
 pcbhsdqper3r, pcbhsdqper4, pcbhsdqper5) .
EXECUTE.

* Hyperactivity scale (5 items).
COMPUTE pcbhsdqhypt = 5 * MEAN.3(pcbhsdqhyp1, pcbhsdqhyp2,
 pcbhsdqhyp3, pcbhsdqhyp4r, pcbhsdqhyp5r).
COMPUTE ppbhsdqhypt1 = 5 * MEAN.3(ppbhsdqhyp11, ppbhsdqhyp21,
 ppbhsdqhyp31, ppbhsdqhyp4r1, ppbhsdqhyp5r1).
COMPUTE ppl2sdqhypt1 = 5 * MEAN.3(ppl2sdqhyp11, ppl2sdqhyp21,
 ppl2sdqhyp31, ppl2sdqhyp4r1, ppl2sdqhyp5r1).
EXECUTE.

* Conduct scale (5 items).
COMPUTE pcbhsdqcont = 5 * MEAN.3(pcbhsdqcon1, pcbhsdqcon2r,
 pcbhsdqcon3, pcbhsdqcon4, pcbhsdqcon5).
COMPUTE ppbhsdqcont1 = 5 * MEAN.3(ppbhsdqcon11, ppbhsdqcon2r1,
 ppbhsdqcon31, ppbhsdqcon41, ppbhsdqcon51).
COMPUTE ppl2sdqcont1 = 5 * MEAN.3(ppl2sdqcon11, ppl2sdqcon2r1,
 ppl2sdqcon31, ppl2sdqcon41, ppl2sdqcon51).
EXECUTE.

* Prosocial scale (5 items).
COMPUTE pcbhsdqprot = 5 * MEAN.3(pcbhsdqpro1, pcbhsdqpro2,
 pcbhsdqpro3, pcbhsdqpro4, pcbhsdqpro5).
COMPUTE ppbhsdqprot1 = 5 * MEAN.3(ppbhsdqpro11, ppbhsdqpro21,
 ppbhsdqpro31, ppbhsdqpro41, ppbhsdqpro51).
COMPUTE ppl2sdqprot1 = 5 * MEAN.3(ppl2sdqpro11, ppl2sdqpro21,
 ppl2sdqpro31, ppl2sdqpro41, ppl2sdqpro51).
EXECUTE.

* Total behaviour problems scale.
* All except prosocial items: 12 for parent, 20 for child (including MFQ item).
COMPUTE pcbhsdqbeht = 20 * MEAN.10(pcbhmfq01, pcbhsdqhyp1, pcbhsdqemo1,
 pcbhsdqcon1, pcbhsdqper1, pcbhsdqcon2r, pcbhsdqemo2, pcbhsdqhyp2, pcbhsdqper2r,
 pcbhsdqcon3, pcbhsdqper3r, pcbhsdqhyp3, pcbhsdqemo4, pcbhsdqcon4, pcbhsdqper4,
 pcbhsdqhyp4r, pcbhsdqcon5, pcbhsdqper5, pcbhsdqemo5, pcbhsdqhyp5r).
COMPUTE ppbhsdqbeht1 = 12 * MEAN.6(ppbhsdqhyp11, ppbhsdqcon11, ppbhsdqcon2r1,
 ppbhsdqhyp21, ppbhsdqcon31, ppbhsdqhyp31, ppbhsdqcon41, ppbhsdqhyp4r1, ppbhsdqcon51,
 ppbhsdqhyp5r1, ppbhsdqper2r1, ppbhsdqper3r1).
COMPUTE ppl2sdqbeht1 = 12 * MEAN.6(ppl2sdqhyp11, ppl2sdqcon11, ppl2sdqcon2r1,
 ppl2sdqhyp21, ppl2sdqcon31, ppl2sdqhyp31, ppl2sdqcon41, ppl2sdqhyp4r1, ppl2sdqcon51,
 ppl2sdqhyp5r1, ppl2sdqper2r1, ppl2sdqper3r1).
EXECUTE.
pcbhshsm1/2, pcshsm1/2

SHS (Subjective Happiness) scales.
Two versions of a total scale derived from all 4 items (reversed where necessary) of the SHS measure, from two sources: (1) child web environment and wellbeing questionnaire part A; (2) child behaviour study booklet.
Items from both sources have integer values 1-7, and each scale is a mean so it has the same range but with decimal values.
In the syntax below, the scales are computed as variables pcshsm and pcbhshsm, which are later copied into variables pcshsm1/2 and pcbhshsm1/2 on double entry.

* SHS total scale (all 4 items).
* Web version, from child EWQA web qnr.
COMPUTE pcshsm = MEAN.2(pcqashs1, pcqashs2, pcqashs3, pcqashs4r).
EXECUTE.

* Booklet version, from child behaviour booklet.
COMPUTE pcbhshsm = MEAN.2(pcbhshs1, pcbhshs2, pcbhshs3, pcbhshs4r) .
EXECUTE.
pcbhsleepdis1/2, pcbhsleepdur1/2, pcbhsleepdys1/2, pcbhsleepeff1/2, pcbhsleeplat1/2, pcbhsleept1/2

Sleep scales: five subscales and a total scale derived from items of the Pittsburgh Sleep Quality Index in the child LEAP/behaviour study booklet.
Sleep latency (pcbhsleeplat1/2) is a subscale derived from items 2 and 5(a).
Sleep duration (pcbhsleepdur1/2) is a subscale derived as a recoding of item 4.
Sleep disturbance (pcbhsleepdis1/2) is a subscale derived from parts (b) to (i) of item 5.
Day dysfunction (pcbhsleepdys1/2) is a subscale derived from items 7 and 8.
Sleep efficiency (pcbhsleepeff1/2) is a subscale derived from items 1, 3 and 4.
The sleep total scale (pcbhsleept1/2) is derived from the above five subscales plus the remaining items 6 and 9.
See comments in the syntax below for details of how each is derived.
These scales are adapted as closely as possible (given category changes in the TEDS item responses) from the published scales. In the syntax below, the scales are computed as variables pcbhsleepXXX, which are later copied into variables pcbhsleepXXX1/2 on double entry.

* PSQI measure included in the twin Leap booklet (not cohort 1).
* New version of scales, sticking as close as possible to the PSQI documentation.
* although adaptations are needed for the TEDS categorical item coding.
* Create 5 new subscales, all with ordinal categories coded 0/1/2/3 (as for most items).
* and a total scale from the 5 subscales plus 2 of the items.
* In all cases, require all relevant items to be non-missing.
* Note that these scales now have integer values without fractions.

* Sleep duration: recode item 4 to 0=7+hours, 1=6-7hours, 2=5-6hours, 3=5-hours.
RECODE pcbhsleep4
 (1=3) (2=2) (3=1) (4=0) (5=0) (6=0) (7=0)
INTO pcbhsleepdur.
EXECUTE.

* Sleep disturbance: recode the sum of items 5b-5i (total 0-24) to 0-3 scale.
* Require all 8 items to be present.
IF (SUM.8(pcbhsleep5b, pcbhsleep5c, pcbhsleep5d, pcbhsleep5e,
   pcbhsleep5f, pcbhsleep5g, pcbhsleep5h, pcbhsleep5i) = 0) pcbhsleepdis = 0.
IF (RANGE(SUM.8(pcbhsleep5b, pcbhsleep5c, pcbhsleep5d, pcbhsleep5e,
   pcbhsleep5f, pcbhsleep5g, pcbhsleep5h, pcbhsleep5i),1,9)) pcbhsleepdis = 1.
IF (RANGE(SUM.8(pcbhsleep5b, pcbhsleep5c, pcbhsleep5d, pcbhsleep5e,
   pcbhsleep5f, pcbhsleep5g, pcbhsleep5h, pcbhsleep5i),10,18)) pcbhsleepdis = 2.
IF (SUM.8(pcbhsleep5b, pcbhsleep5c, pcbhsleep5d, pcbhsleep5e,
   pcbhsleep5f, pcbhsleep5g, pcbhsleep5h, pcbhsleep5i) > 18) pcbhsleepdis = 3.
EXECUTE.

* Latency.
* First recode item 2 to 0-3 scale: 15-=0, 15-30=1, 30+=3.
* (ideally we would code 30-60=2, 60+=3, but the TEDS item only has the 30+ response).
RECODE pcbhsleep2
 (1=0) (2=0) (3=0) (4=1) (5=1) (6=3)
INTO pcbhsleep2x.
EXECUTE.
* Now latency scale 0-3 depends on sum of the above (0-3) and item 5a (also 0-3).
* Require both to be present.
IF (SUM.2(pcbhsleep2x, pcbhsleep5a) = 0) pcbhsleeplat = 0.
IF (RANGE(SUM.2(pcbhsleep2x, pcbhsleep5a),1,2)) pcbhsleeplat = 1.
IF (RANGE(SUM.2(pcbhsleep2x, pcbhsleep5a),3,4)) pcbhsleeplat = 2.
IF (SUM.2(pcbhsleep2x, pcbhsleep5a) > 4) pcbhsleeplat = 3.
EXECUTE.

* Day Dysfunction.
* Recode sum of items 7 and 8 (both 0-3) to overall 0-3 scale.
IF (SUM.2(pcbhsleep7, pcbhsleep8) = 0) pcbhsleepdys = 0.
IF (RANGE(SUM.2(pcbhsleep7, pcbhsleep8),1,2)) pcbhsleepdys = 1.
IF (RANGE(SUM.2(pcbhsleep7, pcbhsleep8),3,4)) pcbhsleepdys = 2.
IF (SUM.2(pcbhsleep7, pcbhsleep8) > 4) pcbhsleepdys = 3.
EXECUTE.

* Sleep Efficiency.
* Compute approximate number of hours in bed.
* from categorical answers to questions 1 and 3.
COMPUTE timeinbed = 9 + pcbhsleep3 - pcbhsleep1.
EXECUTE.
* Now convert actual hours of sleep (Q4) to approximate number of hours.
* so 1=5-hours recoded to 4.5, 2=5-6hours recoded to 5.5 and so on up to 7=10+hours recoded to 10.5.
RECODE pcbhsleep4
 (1=4.5) (2=5.5) (3=6.5) (4=7.5) (5=8.5) (6=9.5) (7=10.5)
INTO sleephours.
EXECUTE.
* Now derive the ratio: hours asleep as a fraction of hours in bed.
COMPUTE sleepratio = sleephours / timeinbed.
EXECUTE.
* This gives a roughly suitable distribution of values between 0 and 1.
* with just a few outliers higher than 1 resulting from categorical approximations.
* and from twins giving inconsistent answers (more hours of sleep than hours in bed).
* Final step: convert sleep ratio to 'sleep efficiency' by recoding.
* into categorical values 0-3, using intervals from published guidance.
RECODE sleepratio (Lowest thru 0.64999=3) (0.65 thru 0.74999=2)
 (0.75 thru 0.84999=1) (0.85 thru Highest=0) 
    INTO pcbhsleepeff.
EXECUTE.

* We can now compute the total Sleep scale as the sum of 7 items and subscales.
* all having values 0-3 (so total has values 0-21).
* This is a sum of sleep duration (recoded version of item 4), sleep disturbance.
* sleep latency, day dysfunction, sleep efficiency and items 6 and 9.
* Require all 7 to be non-missing, hence scale will have only integer values.
COMPUTE pcbhsleept = SUM.7(pcbhsleepdur, pcbhsleepdis, pcbhsleeplat,
 pcbhsleepdys, pcbhsleepeff, pcbhsleep6, pcbhsleep9).
EXECUTE.
pcbhswanhypm1/2, pcbhswaninam1/2, pcbhswanm1/2

SWAN scales.
Total scale (all 18 items) and two subscales (9 items each).
Derived from items of the SWAN measure in the child behaviour study booklet.
Items have integer values 1-7, and the scales are means so have the same range but with decimal values.
In the syntax below, the scales are computed as variables pcbhswanXXXm, which are later copied into variables pcbhswanXXXm1/2 on double entry.

* inattention scale (9 items).
COMPUTE pcbhswaninam = MEAN.5(pcbhswan01, pcbhswan02, pcbhswan03,
 pcbhswan04, pcbhswan05, pcbhswan06, pcbhswan07, pcbhswan08, pcbhswan09) .
EXECUTE .

* hyperactivity scale (9 items).
COMPUTE pcbhswanhypm = MEAN.5(pcbhswan10, pcbhswan11, pcbhswan12,
 pcbhswan13, pcbhswan14, pcbhswan15, pcbhswan16, pcbhswan17, pcbhswan18) .
EXECUTE .

* total scale (all 18 items).
COMPUTE pcbhswanm = MEAN.9(pcbhswan01, pcbhswan02, pcbhswan03,
 pcbhswan04, pcbhswan05, pcbhswan06, pcbhswan07, pcbhswan08, pcbhswan09,
 pcbhswan10, pcbhswan11, pcbhswan12, pcbhswan13, pcbhswan14, pcbhswan15,
 pcbhswan16, pcbhswan17, pcbhswan18) .
EXECUTE .
pcbhtepst1/2, pcl2tepst1/2

TEPS Hedonia scale.
Total scale derived from all 10 items (reversed where necessary) of the TEPS Hedonia measure in the child behaviour/leap/leap-2 study booklet.
Variable pcbhtepst1/2 is from behaviour/leap, while pcl2tepst1/2 is from leap-2.
Each item has integer values 0-5, hence the scale has range 0-50 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcbhtepst (or pcl2tepst), which is later copied into variables pcbhtepst1/2 (or pcl2tepst1/2) on double entry.

* total scale (all 10 items).
COMPUTE pcbhtepst = 10 * MEAN.5(pcbhteps01, pcbhteps02, pcbhteps03r,
 pcbhteps04, pcbhteps05, pcbhteps06, pcbhteps07, pcbhteps08, pcbhteps09, pcbhteps10).
COMPUTE pcl2tepst = 10 * MEAN.5(pcl2teps01, pcl2teps02, pcl2teps03r,
 pcl2teps04, pcl2teps05, pcl2teps06, pcl2teps07, pcl2teps08, pcl2teps09, pcl2teps10).
EXECUTE.
pcbmi1/2

Twin BMI, measured in kg per square metre.
Derived from self-reported height and weight items, from web environment and wellbeing questionnaire D.
Computed as variable pcbmi in the syntax below, which is copied to variables pcbmi1/2 on double entry.

* Height variable is in centimetres.
* We want BMI in units of kilograms per square metre.
* So include a scaling factor of 10000 in the BMI calculation.
COMPUTE pcbmi = 10000 * pcqdwtkg / (pcqdhtcm * pcqdhtcm).
EXECUTE.
pccbatm1/2, pcdnatm1/2, pcflatm1/2, pcnlatm1/2, pcnsatm1/2, pcpsatm1/2, pcpvatm1/2, pcrtatm1/2, pcrvatm1/2, pcunatm1/2, pcvcatm1/2, pcynatm1/2

Mean item answer time, in seconds, for each of the 12 timed web activities.
Computed simply as the mean of all the item answer times for each activity.
This excludes the four environment and wellbeing web questionnaires, for which answer times were not recorded.
Computed as variables pcXXatm in the syntax below, and later copied to variables pcXXatm1/2 on double entry.

* Compute mean answer times for each timed web activity.
* For passages, include the two passages reading times as well as the answer times.
COMPUTE pcunatm = MEAN(pcun01at, pcun02at, pcun03at, pcun04at, pcun05at, pcun06at,
 pcun07at, pcun08at, pcun09at, pcun10at, pcun11at, pcun12at, pcun13at, pcun14at,
 pcun15at, pcun16at, pcun17at, pcun18at).
COMPUTE pcdnatm = MEAN(pcdn01at, pcdn02at, pcdn03at, pcdn04at, pcdn05at, pcdn06at,
 pcdn07at, pcdn08at, pcdn09at, pcdn10at, pcdn11at, pcdn12at, pcdn13at, pcdn14at,
 pcdn15at, pcdn16at, pcdn17at, pcdn18at, pcdn19at, pcdn20at, pcdn21at, pcdn22at,
 pcdn23at, pcdn24at, pcdn25at, pcdn26at, pcdn27at, pcdn28at, pcdn29at, pcdn30at,
 pcdn31at, pcdn32at, pcdn33at, pcdn34at, pcdn35at, pcdn36at).
COMPUTE pcnlatm = MEAN(pcnl01at, pcnl02at, pcnl03at, pcnl04at, pcnl05at, pcnl06at,
 pcnl07at, pcnl08at, pcnl09at, pcnl10at, pcnl11at, pcnl12at, pcnl13at, pcnl14at,
 pcnl15at, pcnl16at, pcnl17at, pcnl18at, pcnl19at, pcnl20at, pcnl21at, pcnl22at).
COMPUTE pcnsatm = MEAN(pcns001at, pcns002at, pcns003at, pcns004at, pcns005at, pcns006at,
 pcns007at, pcns008at, pcns009at, pcns010at, pcns011at, pcns012at, pcns013at, pcns014at,
 pcns015at, pcns016at, pcns017at, pcns018at, pcns019at, pcns020at, pcns021at, pcns022at,
 pcns023at, pcns024at, pcns025at, pcns026at, pcns027at, pcns028at, pcns029at, pcns030at,
 pcns031at, pcns032at, pcns033at, pcns034at, pcns035at, pcns036at, pcns037at, pcns038at,
 pcns039at, pcns040at, pcns041at, pcns042at, pcns043at, pcns044at, pcns045at, pcns046at,
 pcns047at, pcns048at, pcns049at, pcns050at, pcns051at, pcns052at, pcns053at, pcns054at,
 pcns055at, pcns056at, pcns057at, pcns058at, pcns059at, pcns060at, pcns061at, pcns062at,
 pcns063at, pcns064at, pcns065at, pcns066at, pcns067at, pcns068at, pcns069at, pcns070at,
 pcns071at, pcns072at, pcns073at, pcns074at, pcns075at, pcns076at, pcns077at, pcns078at,
 pcns079at, pcns080at, pcns081at, pcns082at, pcns083at, pcns084at, pcns085at, pcns086at,
 pcns087at, pcns088at, pcns089at, pcns090at, pcns091at, pcns092at, pcns093at, pcns094at,
 pcns095at, pcns096at, pcns097at, pcns098at, pcns099at, pcns100at, pcns101at, pcns102at,
 pcns103at, pcns104at, pcns105at, pcns106at, pcns107at, pcns108at, pcns109at, pcns110at,
 pcns111at, pcns112at, pcns113at, pcns114at, pcns115at, pcns116at, pcns117at, pcns118at,
 pcns119at, pcns120at, pcns121at, pcns122at, pcns123at, pcns124at, pcns125at, pcns126at,
 pcns127at, pcns128at, pcns129at, pcns130at, pcns131at, pcns132at, pcns133at, pcns134at,
 pcns135at, pcns136at, pcns137at, pcns138at, pcns139at, pcns140at, pcns141at, pcns142at,
 pcns143at, pcns144at, pcns145at, pcns146at, pcns147at, pcns148at, pcns149at, pcns150at).
COMPUTE pcpvatm = MEAN(pcpv01at, pcpv02at, pcpv03at, pcpv04at, pcpv05at, pcpv06at,
 pcpv07at, pcpv08at, pcpv09at, pcpv10at, pcpv11at, pcpv12at, pcpv13at, pcpv14at,
 pcpv15at, pcpv16at, pcpv17at, pcpv18at, pcpv19at, pcpv20at, pcpv21at, pcpv22at,
 pcpv23at, pcpv24at, pcpv25at, pcpv26at, pcpv27at, pcpv28at, pcpv29at, pcpv30at,
 pcpv31at, pcpv32at, pcpv33at, pcpv34at, pcpv35at, pcpv36at, pcpv37at, pcpv38at,
 pcpv39at, pcpv40at, pcpv41at, pcpv42at, pcpv43at, pcpv44at, pcpv45at, pcpv46at,
 pcpv47at, pcpv48at).
COMPUTE pcrtatm = MEAN(pcrt01at, pcrt02at, pcrt03at, pcrt04at, pcrt05at, pcrt06at,
 pcrt07at, pcrt08at, pcrt09at, pcrt10at, pcrt11at, pcrt12at, pcrt13at, pcrt14at,
 pcrt15at, pcrt16at, pcrt17at, pcrt18at, pcrt19at, pcrt20at, pcrt21at, pcrt22at,
 pcrt23at, pcrt24at, pcrt25at, pcrt26at, pcrt27at, pcrt28at, pcrt29at, pcrt30at,
 pcrt31at, pcrt32at, pcrt33at, pcrt34at, pcrt35at, pcrt36at, pcrt37at, pcrt38at,
 pcrt39at, pcrt40at).
COMPUTE pccbatm = MEAN(pccb41at, pccb42at, pccb51at, pccb52at, pccb61at,
 pccb62at, pccb71at, pccb72at, pccb81at, pccb82at, pccb91at, pccb92at).
COMPUTE pcvcatm = MEAN(pcvc01at, pcvc02at, pcvc03at, pcvc04at, pcvc05at, pcvc06at,
 pcvc07at, pcvc08at, pcvc09at, pcvc10at, pcvc11at, pcvc12at, pcvc13at, pcvc14at,
 pcvc15at, pcvc16at, pcvc17at, pcvc18at, pcvc19at, pcvc20at, pcvc21at, pcvc22at,
 pcvc23at, pcvc24at, pcvc25at, pcvc26at, pcvc27at, pcvc28at, pcvc29at, pcvc30at,
 pcvc31at, pcvc32at, pcvc33at).
COMPUTE pcrvatm = MEAN(pcrvc01at, pcrvc03at, pcrvc05at, pcrvc07at, pcrvc09at, pcrvc11at,
 pcrvd01at, pcrvd03at, pcrvd05at, pcrvd07at, pcrvd09at, pcrvd11at, pcrve01at, pcrve03at,
 pcrve05at, pcrve07at, pcrve09at, pcrve11at, pcrvf01at, pcrvf02at, pcrvf03at, pcrvf04at,
 pcrvf05at, pcrvf06at, pcrvf07at, pcrvf08at, pcrvf09at, pcrvf10at, pcrvf11at, pcrvf12at).
COMPUTE pcpsatm = MEAN(pcps1rdt, pcps2rdt, pcps101at, pcps102at, pcps103at, pcps104at,
 pcps105at, pcps106at,
 pcps107at, pcps108at, pcps109at, pcps110at, pcps111at, pcps112at, pcps113at, pcps201at,
 pcps202at, pcps203at, pcps204at, pcps205at, pcps206at, pcps207at, pcps208at, pcps209at,
 pcps210at, pcps211at, pcps212at, pcps213at).
COMPUTE pcynatm = MEAN(pcyn01at, pcyn02at, pcyn03at, pcyn04at, pcyn05at, pcyn06at, pcyn07at,
 pcyn08at, pcyn09at, pcyn10at, pcyn11at, pcyn12at, pcyn13at, pcyn14at, pcyn15at, pcyn16at,
 pcyn17at, pcyn18at, pcyn19at, pcyn20at, pcyn21at, pcyn22at, pcyn23at, pcyn24at, pcyn25at,
 pcyn26at, pcyn27at, pcyn28at, pcyn29at, pcyn30at, pcyn31at, pcyn32at, pcyn33at, pcyn34at,
 pcyn35at, pcyn36at, pcyn37at, pcyn38at, pcyn39at, pcyn40at, pcyn41at, pcyn42at, pcyn43at,
 pcyn44at, pcyn45at, pcyn46at, pcyn47at, pcyn48at, pcyn49at, pcyn50at, pcyn51at, pcyn52at,
 pcyn53at, pcyn54at, pcyn55at, pcyn56at, pcyn57at, pcyn58at, pcyn59at, pcyn60at, pcyn61at,
 pcyn62at, pcyn63at, pcyn64at, pcyn65at, pcyn66at, pcyn67at, pcyn68at, pcyn69at, pcyn70at,
 pcyn71at, pcyn72at, pcyn73at, pcyn74at, pcyn75at, pcyn76at, pcyn77at, pcyn78at, pcyn79at,
 pcyn80at, pcyn81at, pcyn82at, pcyn83at, pcyn84at, pcyn85at, pcyn86at, pcyn87at, pcyn88at,
 pcyn89at, pcyn90at, pcyn91at, pcyn92at, pcyn93at, pcyn94at, pcyn95at, pcyn96at, pcyn97at,
 pcyn98at).
COMPUTE pcflatm = MEAN(pcfl01at, pcfl02at, pcfl03at, pcfl04at, pcfl05at, pcfl06at,
 pcfl07at, pcfl08at, pcfl09at, pcfl10at, pcfl11at, pcfl12at, pcfl13at, pcfl14at, pcfl15at).
EXECUTE.
pcchatot1/2

Chaos at home scale.
Derived from all 6 items (reversed where necessary) of the chaos measure in child web environment and wellbeing questionnaire part A.
Each item has integer values 0-2, hence the scale has range 0-12 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcchatot, which is later copied into variables pcchatot1/2 on double entry.

* create scale, requiring over half the items to be non-missing.
COMPUTE pcchatot = 6 * MEAN.4(pcqachaos1r, pcqachaos2,
  pcqachaos3, pcqachaos4r, pcqachaos5, pcqachaos6r).
EXECUTE.
pccuriexm1/2, pccuriflm1/2, pccurim1/2

Curiosity scales.
Total scale and two subscales.
Derived from items (reversed where necessary) of the Curiosity measure in child web environment and wellbeing questionnaire part A.
Items have integer values 1-7, and the scales are means so have the same range but with decimal values.
In the syntax below, the scales are computed as variables pccuriXXXm, which are later copied into variables pccuriXXXm1/2 on double entry.

* Explore subscale (items 1, 3, 4, 7).
COMPUTE pccuriexm = MEAN.2(pcqacuri1, pcqacuri3, pcqacuri4r, pcqacuri7).
EXECUTE .
* Flow subscale (items 2, 5, 6).
COMPUTE pccuriflm = MEAN.2(pcqacuri2, pcqacuri5, pcqacuri6).
EXECUTE .
* Total scale (all 7 items).
COMPUTE pccurim = MEAN.4(pcqacuri1, pcqacuri2, pcqacuri3, pcqacuri4r, pcqacuri5, pcqacuri6, pcqacuri7).
EXECUTE .
pcdisnegt1/2, pcdispost1/2

Parental discipline subscales.
Derived from the 4 items of the parental discipline measure in child web environment and wellbeing questionnaire part C.
Items have integer values 0-2 and each subscale is derived as a scaled mean of 2 items, hence each subscale has a range of values from 0 to 4.

* Parental discipline.
* Derive positive and negative discipline subscales comparable with other ages.
* Negative/harsh discipline (2 items).
COMPUTE pcdisnegt = 2 * MEAN.1(pcqcpadi1, pcqcpadi3).
* Positive discipline (2 items).
COMPUTE pcdispost = 2 * MEAN.1(pcqcpadi2, pcqcpadi4).
EXECUTE.
pcdnatm1/2

See pccbatm1/2, etc above.

pcexage1/2

See pcbhage1/2, etc above.

pcexgcseage1/2

See pcbhage1/2, etc above.

pcexallmatgrdm1/2, pcexallenggrdm1/2, pcexallscigrdm1/2, pcexalltecgrdm1/2, pcexallhumgrdm1/2, pcexalllangrdm1/2, pcexallvocgrdm1/2, pcexallgrdm1/2, pcexallcoregrdm1/2

Mean grades for all qualification types (GCSE + others combined). Each qualification may have grades between 1 and 11, where 4-11 are GCSE-equivalent grades and 1-3 are sub-GCSE Entry Level grades. Hence each of these mean grade variables has values ranging from 1 to 11.
Separate variables are derived in 7 subject groups, plus an overall total, plus the combined core subjects (Maths, English and Science). The derived variables are:
pcexallmatgrdm: Maths
pcexallenggrdm: English
pcexallscigrdm: Science
pcexalltecgrdm: technology
pcexallhumgrdm: humanities
pcexalllangrdm: languages
pcexallvocgrdm: vocational subjects
pcexallgrdm: all subjects combined
pcexallcoregrdm: core subjects combined.
They are derived from point scores and numbers of qualifications, which are themselves derived variables described elsewhere on this page.

* Overall mean grades, combining GCSE with other qualification results.
* Obtain the mean grades by division, rounding to 0.1.
* checking first to ensure that at least one result exists.
IF (pcexallmatnum > 0) pcexallmatgrdm = RND((pcexallmatpsct / pcexallmatnum), 0.1).
IF (pcexallengnum > 0) pcexallenggrdm = RND((pcexallengpsct / pcexallengnum), 0.1).
IF (pcexallscinum > 0) pcexallscigrdm = RND((pcexallscipsct / pcexallscinum), 0.1).
IF (pcexalltecnum > 0) pcexalltecgrdm = RND((pcexalltecpsct / pcexalltecnum), 0.1).
IF (pcexallhumnum > 0) pcexallhumgrdm = RND((pcexallhumpsct / pcexallhumnum), 0.1).
IF (pcexalllannum > 0) pcexalllangrdm = RND((pcexalllanpsct / pcexalllannum), 0.1).
IF (pcexallvocnum > 0) pcexallvocgrdm = RND((pcexallvocpsct / pcexallvocnum), 0.1).
IF (pcexallnum > 0) pcexallgrdm = RND((pcexallpsct / pcexallnum), 0.1).
EXECUTE.
* Core subjects: sum over English, maths and science.
* and require at least 2 of the 3 subjects to be non-missing.
IF (SUM.2(pcexallmatnum, pcexallengnum, pcexallscinum) > 0)
    pcexallcoregrdm = RND(((SUM(pcexallmatpsct, pcexallengpsct, pcexallscipsct))
     / (SUM(pcexallmatnum, pcexallengnum, pcexallscinum))), 0.1).
EXECUTE.
pcexallmatnum1/2, pcexallengnum1/2, pcexallscinum1/2, pcexalltecnum1/2, pcexallhumnum1/2, pcexalllannum1/2, pcexallvocnum1/2, pcexallnum1/2, pcexallcorenum1/2

Number of all qualification types (GCSE + others combined). Numbers are measured in terms of the equivalents to GCSEs in workload or curriculum time, as specified by the NQF, where a single GCSE result has value 1.
Separate variables are derived in 7 subject groups, plus an overall total. The derived variables are:
pcexallmatnum: Maths
pcexallengnum: English
pcexallscinum: Science
pcexalltecnum: technology
pcexallhumnum: humanities
pcexalllannum: languages
pcexallvocnum: vocational subjects
pcexallnum: all subjects combined.
They are derived from numbers of qualifications already derived separately for GCSEs and for all other equivalent qualification types. These other derived variables are described elsewhere on this page.

* Overall number of qualifications (GCSE equivalents): simply sum GCSE and non-GCSE.
COMPUTE pcexallmatnum = SUM(pcexgcsematnum, pcexothermatnum).
COMPUTE pcexallengnum = SUM(pcexgcseengnum, pcexotherengnum).
COMPUTE pcexallscinum = SUM(pcexgcsescinum, pcexotherscinum).
COMPUTE pcexalltecnum = SUM(pcexgcsetecnum, pcexothertecnum).
COMPUTE pcexallhumnum = SUM(pcexgcsehumnum, pcexotherhumnum).
COMPUTE pcexalllannum = SUM(pcexgcselannum, pcexotherlannum).
COMPUTE pcexallvocnum = SUM(pcexgcsevocnum, pcexothervocnum).
COMPUTE pcexallnum = SUM(pcexgcsenum, pcexothernum).
EXECUTE.
pcexallmatpsct1/2, pcexallengpsct1/2, pcexallscipsct1/2, pcexalltecpsct1/2, pcexallhumpsct1/2, pcexalllanpsct1/2, pcexallvocpsct1/2, pcexallpsct1/2

Point scores, combining all qualification types (GCSE + others). Point scores are derived by multiplying the grade score by the award value (workload) for each recorded qualification, then summing in the appropriate subject group. Each qualification may have a grade value from 1 to 11, and a workload value of 0.5, 1, 2, etc. Hence, after summing over a set of qualifications, the point score may have a wide range of values from 0 upwards (a value of zero indicates no qualifications in the given category).
Separate variables are derived in 7 subject groups, plus an overall total as follows:
pcexallmatpsct: Maths
pcexallengpsct: English
pcexallscipsct: Science
pcexalltecpsct: technology
pcexallhumpsct: humanities
pcexalllanpsct: languages
pcexallvocpsct: vocational subjects
pcexallpsct: all subjects combined.
Here, the overall point score in each category is derived simply by summing the point score already derived for GCSE results with the point score already derived for other, non-GCSE results. These separate point scores are documented elsewhere on this page.

* Overall point scores: simply sum GCSE and non-GCSE.
COMPUTE pcexallmatpsct = SUM(pcexgcsematpsct, pcexothermatpsct).
COMPUTE pcexallengpsct = SUM(pcexgcseengpsct, pcexotherengpsct).
COMPUTE pcexallscipsct = SUM(pcexgcsescipsct, pcexotherscipsct).
COMPUTE pcexalltecpsct = SUM(pcexgcsetecpsct, pcexothertecpsct).
COMPUTE pcexallhumpsct = SUM(pcexgcsehumpsct, pcexotherhumpsct).
COMPUTE pcexalllanpsct = SUM(pcexgcselanpsct, pcexotherlanpsct).
COMPUTE pcexallvocpsct = SUM(pcexgcsevocpsct, pcexothervocpsct).
COMPUTE pcexallpsct = SUM(pcexgcsepsct, pcexotherpsct).
EXECUTE.
pcexgcseLLCage, pcexgcseLLCdate

See pcbhLLCage1/2, etc above.

pcexgcsematgrdm1/2, pcexgcseenggrdm1/2, pcexgcsescigrdm1/2, pcexgcsetecgrdm1/2, pcexgcsehumgrdm1/2, pcexgcselangrdm1/2, pcexgcsevocgrdm1/2, pcexgcsegrdm1/2, pcexgcsecoregrdm1/2

Mean grades for GCSEs, excluding other qualification types. Each GCSE may have grade values between 4 (grade G) and 11 (grade A*). Hence each of these mean grade variables has values ranging from 4 to 11.
Separate variables are derived in 7 subject groups, plus an overall total, plus the combined core subjects (Maths, English and Science). The derived variables are:
pcexgcsematgrdm: Maths
pcexgcseenggrdm: English
pcexgcsescigrdm: Science
pcexgcsetecgrdm: technology
pcexgcsehumgrdm: humanities
pcexgcselangrdm: languages
pcexgcsevocgrdm: vocational subjects
pcexgcsegrdm: all subjects combined
pcexgcsecoregrdm: core subjects combined.
The mean grades are derived from point scores and numbers of qualifications, which are themselves derived variables described elsewhere on this page.

* GCSE mean grades.
* In the 7 subject groups and overall, and with the addition of 'core subject' mean.
* that combines English, maths and science.
* The mean grade equals the point score divided by the number of GCSEs.
* but check that the latter is non-zero before attempting to divide.
* Also, round to nearest 0.1 because these results do not merit higher precision.
IF (pcexgcsematnum > 0) pcexgcsematgrdm = RND((pcexgcsematpsct / pcexgcsematnum), 0.1).
IF (pcexgcseengnum > 0) pcexgcseenggrdm = RND((pcexgcseengpsct / pcexgcseengnum), 0.1).
IF (pcexgcsescinum > 0) pcexgcsescigrdm = RND((pcexgcsescipsct / pcexgcsescinum), 0.1).
IF (pcexgcsetecnum > 0) pcexgcsetecgrdm = RND((pcexgcsetecpsct / pcexgcsetecnum), 0.1).
IF (pcexgcsehumnum > 0) pcexgcsehumgrdm = RND((pcexgcsehumpsct / pcexgcsehumnum), 0.1).
IF (pcexgcselannum > 0) pcexgcselangrdm = RND((pcexgcselanpsct / pcexgcselannum), 0.1).
IF (pcexgcsevocnum > 0) pcexgcsevocgrdm = RND((pcexgcsevocpsct / pcexgcsevocnum), 0.1).
IF (pcexgcsenum > 0) pcexgcsegrdm = RND((pcexgcsepsct / pcexgcsenum), 0.1).
EXECUTE.
* Core subjects: sum over English, maths and science.
* and require at least 2 of the 3 subjects to be non-missing.
IF (SUM.2(pcexgcsematnum, pcexgcseengnum, pcexgcsescinum) > 0)
    pcexgcsecoregrdm = RND(((SUM(pcexgcsematpsct, pcexgcseengpsct, pcexgcsescipsct))
     / (SUM(pcexgcsematnum, pcexgcseengnum, pcexgcsescinum))), 0.1).
EXECUTE.
pcexgcsematnum1/2, pcexgcseengnum1/2, pcexgcsescinum1/2, pcexgcsetecnum1/2, pcexgcsehumnum1/2, pcexgcselannum1/2, pcexgcsevocnum1/2, pcexgcsenum1/2, pcexgcseabcnum1/2

Number of all GCSE results. Numbers are measured in terms of the equivalents to GCSEs in workload or curriculum time, as specified by the NQF, where a single GCSE result has value 1 and a half-GCSE has value 0.5.
Separate variables are derived in 7 subject groups, plus an overall total. Additionally, there is a variable that counts the number of results at grades A* to C across all subjects. The derived variables are:
pcexgcsematnum: Maths
pcexgcseengnum: English
pcexgcsescinum: Science
pcexgcsetecnum: technology
pcexgcsehumnum: humanities
pcexgcselannum: languages
pcexgcsevocnum: vocational subjects
pcexgcsenum: all subjects combined.
pcexgcseabcnum: number of results at grades A* to C, in all subjects.
These numbers are derived from item variables in the raw GCSE data.

* Numbers of GCSEs.
* First, count the number of results overall and in each of 7 subject categories.
* Count short-course GCSE results as half a GCSE, hence can have decimal totals.
* To simplify the counting, recode the raw GCSE variables into value flags.
* with values 1=full GCSE, 0.5=half GCSE, otherwise missing.
RECODE pcexgcseenla pcexgcseenli pcexgcsemdst pcexgcsemath pcexgcsestat
 pcexgcsescic pcexgcsescia pcexgcsebiol pcexgcsechem pcexgcsephys pcexgcsehist
 pcexgcsegeog pcexgcsere pcexgcsefren pcexgcsegerm pcexgcsespan pcexgcsedt pcexgcseict
 pcexgcsebsst pcexgcseart pcexgcsepe pcexgcsedram pcexgcsemusc
 (4 THRU 11=1) (ELSE=SYSMIS)
INTO pcexgcseenlaN pcexgcseenliN pcexgcsemdstN pcexgcsemathN pcexgcsestatN 
 pcexgcsescicN pcexgcsesciaN pcexgcsebiolN pcexgcsechemN pcexgcsephysN pcexgcsehistN 
 pcexgcsegeogN pcexgcsereN pcexgcsefrenN pcexgcsegermN pcexgcsespanN pcexgcsedtN pcexgcseictN 
 pcexgcsebsstN pcexgcseartN pcexgcsepeN pcexgcsedramN pcexgcsemuscN .
EXECUTE.
RECODE pcexsgcsere pcexsgcsecitz pcexsgcseict
 (4 THRU 11=0.5) (ELSE=SYSMIS)
INTO pcexsgcsereN pcexsgcsecitzN pcexsgcseictN.
EXECUTE.
* Maths - includes maths, statistics.
COMPUTE pcexgcsematnum = SUM(pcexgcsemathN, pcexgcsestatN).
* English - includes language and literature.
COMPUTE pcexgcseengnum = SUM(pcexgcseenlaN, pcexgcseenliN).
* Science - includes science (core + additional), biology, chemistry, physics.
COMPUTE pcexgcsescinum = SUM(pcexgcsescicN, pcexgcsesciaN, pcexgcsebiolN, pcexgcsechemN, pcexgcsephysN).
* Technology - includes DT and IT (also present as a half-gcse).
COMPUTE pcexgcsetecnum = SUM(pcexsgcseictN, pcexgcsedtN, pcexgcseictN).
* Humanities - includes geography, history, RE and citizenship (also present as half-GCSEs).
*  media studies, art, music, drama.
COMPUTE pcexgcsehumnum = SUM(pcexsgcsereN, pcexsgcsecitzN, pcexgcsemdstN, pcexgcsehistN, 
 pcexgcsegeogN, pcexgcsereN, pcexgcseartN, pcexgcsedramN, pcexgcsemuscN).
* Languages - includes French, German, Spanish.
COMPUTE pcexgcselannum = SUM(pcexgcsefrenN, pcexgcsegermN, pcexgcsespanN).
* Vocational - includes PE, business studies.
COMPUTE pcexgcsevocnum = SUM(pcexgcsebsstN, pcexgcsepeN).
EXECUTE.
* Now add miscellaneous 'others' whose subjects are already coded 1-7 for the above subject groups.
* There are 4 full-GCSE 'other' variables and 1 half-GCSE 'other' that may be recorded.
* Note that these do not include English or Science results.
COUNT matoth = pcexgcseoth1s pcexgcseoth2s pcexgcseoth3s pcexgcseoth4s (1).
COUNT tecoth = pcexgcseoth1s pcexgcseoth2s pcexgcseoth3s pcexgcseoth4s (4).
COUNT humoth = pcexgcseoth1s pcexgcseoth2s pcexgcseoth3s pcexgcseoth4s (5).
COUNT lanoth = pcexgcseoth1s pcexgcseoth2s pcexgcseoth3s pcexgcseoth4s (6).
COUNT vocoth = pcexgcseoth1s pcexgcseoth2s pcexgcseoth3s pcexgcseoth4s (7).
EXECUTE.
* Counts as derived above are 0 by default if variables are missing, so recode.
RECODE matoth tecoth humoth lanoth vocoth (0=SYSMIS).
EXECUTE.
* Add these to the totals, using SUM in case missing.
COMPUTE pcexgcsematnum = SUM(pcexgcsematnum, matoth).
COMPUTE pcexgcsetecnum = SUM(pcexgcsetecnum, tecoth).
COMPUTE pcexgcsehumnum = SUM(pcexgcsehumnum, humoth).
COMPUTE pcexgcselannum = SUM(pcexgcselannum, lanoth).
COMPUTE pcexgcsevocnum = SUM(pcexgcsevocnum, vocoth).
EXECUTE.
* and add the other half-GCSE if it exists.
IF (pcexsgcseoths = 1) pcexgcsematnum = SUM(pcexgcsematnum, 0.5).
IF (pcexsgcseoths = 4) pcexgcsetecnum = SUM(pcexgcsetecnum, 0.5).
IF (pcexsgcseoths = 5) pcexgcsehumnum = SUM(pcexgcsehumnum, 0.5).
IF (pcexsgcseoths = 6) pcexgcselannum = SUM(pcexgcselannum, 0.5).
IF (pcexsgcseoths = 7) pcexgcsevocnum = SUM(pcexgcsevocnum, 0.5).
EXECUTE.
* These counts are now complete for all subject groups.
* We can therefore sum to give the total number of GCSE results.
COMPUTE pcexgcsenum = SUM(pcexgcsematnum, pcexgcseengnum, pcexgcsescinum, 
  pcexgcsetecnum, pcexgcsehumnum, pcexgcselannum, pcexgcsevocnum).
EXECUTE.
* All the counts above have missing values by default.
* Recode missing to 0 if exam results data were collected.
DO IF (pcexdata = 1).
 RECODE pcexgcsematnum pcexgcseengnum pcexgcsescinum pcexgcsetecnum pcexgcsehumnum pcexgcselannum 
    pcexgcsevocnum pcexgcsenum (SYSMIS=0).
END IF.
EXECUTE.

* 24 twins with no GCSE results need to have pcecnogcse corrected from 0 to 1.
IF (pcexnogcse = 0 & pcexgcsenum = 0) pcexnogcse = 1.
EXECUTE.

* Also, count number of GCSEs with grades A* to C (coded 8-11).
* across all subject groups.
COUNT pcexgcseabcnum = pcexgcseenla pcexgcseenli pcexgcsemdst pcexgcsemath pcexgcsestat
 pcexgcsescic pcexgcsescia pcexgcsebiol pcexgcsechem pcexgcsephys pcexgcsehist
 pcexgcsegeog pcexgcsere pcexgcsefren pcexgcsegerm pcexgcsespan pcexgcsedt pcexgcseict
 pcexgcsebsst pcexgcseart pcexgcsepe pcexgcsedram pcexgcsemusc
 pcexgcseoth1g pcexgcseoth2g pcexgcseoth3g pcexgcseoth4g (8 thru 11).
EXECUTE.
* add short courses, counting as half.
IF (pcexsgcsere > 7) pcexgcseabcnum = SUM(pcexgcseabcnum, 0.5) .
IF (pcexsgcsecitz > 7) pcexgcseabcnum = SUM(pcexgcseabcnum, 0.5) .
IF (pcexsgcseict > 7) pcexgcseabcnum = SUM(pcexgcseabcnum, 0.5) .
IF (pcexsgcseothsg > 7) pcexgcseabcnum = SUM(pcexgcseabcnum, 0.5) .
EXECUTE.
* recode this count from 0 to missing if there are no exam results data.
* (the COUNT expression above gives result 0 if all data are missing).
DO IF (pcexdata = 0).
 RECODE pcexgcseabcnum (ELSE=SYSMIS).
END IF.
EXECUTE.
pcexgcsematpsct1/2, pcexgcseengpsct1/2, pcexgcsescipsct1/2, pcexgcsetecpsct1/2, pcexgcsehumpsct1/2, pcexgcselanpsct1/2, pcexgcsevocpsct1/2, pcexgcsepsct1/2

Point scores for GCSE results, excluding other qualification types. Point scores are derived by multiplying the grade score by the award value (workload) for each recorded qualification, then summing in the appropriate subject group. Each GCSE may have a grade value from 4 (grade G) to 11 (grade A*), and a workload value of 0.5 or 1. Hence, after summing over a set of GCSE, the point score may have a wide range of values from 0 upwards (a value of zero indicates no GCSE results in the given category).
Separate variables are derived in 7 subject groups, plus an overall total as follows:
pcexgcsematpsct: Maths
pcexgcseengpsct: English
pcexgcsescipsct: Science
pcexgcsetecpsct: technology
pcexgcsehumpsct: humanities
pcexgcselanpsct: languages
pcexgcsevocpsct: vocational subjects
pcexgcsepsct: all subjects combined.
The point scores are derived from item variables in the raw GCSE data. Detailed explanation is given in comments in the syntax below.

* GCSE point scores.
* Point score is derived by summing the grade values (4 to 11).
* for the GCSE results, each result having weight 1 for a full GCSE.
* or 0.5 for a half-GCSE.
* First sum the grade values for the full GCSEs, by subject group.
* Maths.
COMPUTE pcexgcsematpsct = SUM(pcexgcsemath, pcexgcsestat).
* English.
COMPUTE pcexgcseengpsct = SUM(pcexgcseenla, pcexgcseenli).
* Science.
COMPUTE pcexgcsescipsct = SUM(pcexgcsescic, pcexgcsescia, pcexgcsebiol, pcexgcsechem, pcexgcsephys).
* Technology (including half-GCSE IT).
COMPUTE pcexgcsetecpsct = SUM((pcexsgcseict * 0.5), pcexgcsedt, pcexgcseict).
* Humanities (including half-GCSE RE and citizenship).
COMPUTE pcexgcsehumpsct = SUM((pcexsgcsere * 0.5), (pcexsgcsecitz * 0.5), pcexgcsemdst, pcexgcsehist, 
 pcexgcsegeog, pcexgcsere, pcexgcseart, pcexgcsedram, pcexgcsemusc).
* Languages.
COMPUTE pcexgcselanpsct = SUM(pcexgcsefren, pcexgcsegerm, pcexgcsespan).
* Vocational.
COMPUTE pcexgcsevocpsct = SUM(pcexgcsebsst, pcexgcsepe).
EXECUTE.
* Now add grades from the 'other' GCSE variables.
* For this, we need to check the subject code (1-7).
*  then add the grade points to the appropriate variable.
* Note again that the 'others' do not include English or science subjects.
* Other half-GCSE.
IF (pcexsgcseoths = 1) pcexgcsematpsct = SUM(pcexgcsematpsct, (0.5 * pcexsgcseothsg)).
IF (pcexsgcseoths = 4) pcexgcsetecpsct = SUM(pcexgcsetecpsct, (0.5 * pcexsgcseothsg)).
IF (pcexsgcseoths = 5) pcexgcsehumpsct = SUM(pcexgcsehumpsct, (0.5 * pcexsgcseothsg)).
IF (pcexsgcseoths = 6) pcexgcselanpsct = SUM(pcexgcselanpsct, (0.5 * pcexsgcseothsg)).
IF (pcexsgcseoths = 7) pcexgcsevocpsct = SUM(pcexgcsevocpsct, (0.5 * pcexsgcseothsg)).
EXECUTE.
* Other full-GCSEs (variables for up to 4 of these).
IF (pcexgcseoth1s = 1) pcexgcsematpsct = SUM(pcexgcsematpsct, pcexgcseoth1g).
IF (pcexgcseoth1s = 4) pcexgcsetecpsct = SUM(pcexgcsetecpsct, pcexgcseoth1g).
IF (pcexgcseoth1s = 5) pcexgcsehumpsct = SUM(pcexgcsehumpsct, pcexgcseoth1g).
IF (pcexgcseoth1s = 6) pcexgcselanpsct = SUM(pcexgcselanpsct, pcexgcseoth1g).
IF (pcexgcseoth1s = 7) pcexgcsevocpsct = SUM(pcexgcsevocpsct, pcexgcseoth1g).
EXECUTE.
IF (pcexgcseoth2s = 1) pcexgcsematpsct = SUM(pcexgcsematpsct, pcexgcseoth2g).
IF (pcexgcseoth2s = 4) pcexgcsetecpsct = SUM(pcexgcsetecpsct, pcexgcseoth2g).
IF (pcexgcseoth2s = 5) pcexgcsehumpsct = SUM(pcexgcsehumpsct, pcexgcseoth2g).
IF (pcexgcseoth2s = 6) pcexgcselanpsct = SUM(pcexgcselanpsct, pcexgcseoth2g).
IF (pcexgcseoth2s = 7) pcexgcsevocpsct = SUM(pcexgcsevocpsct, pcexgcseoth2g).
EXECUTE.
IF (pcexgcseoth3s = 1) pcexgcsematpsct = SUM(pcexgcsematpsct, pcexgcseoth3g).
IF (pcexgcseoth3s = 4) pcexgcsetecpsct = SUM(pcexgcsetecpsct, pcexgcseoth3g).
IF (pcexgcseoth3s = 5) pcexgcsehumpsct = SUM(pcexgcsehumpsct, pcexgcseoth3g).
IF (pcexgcseoth3s = 6) pcexgcselanpsct = SUM(pcexgcselanpsct, pcexgcseoth3g).
IF (pcexgcseoth3s = 7) pcexgcsevocpsct = SUM(pcexgcsevocpsct, pcexgcseoth3g).
EXECUTE.
IF (pcexgcseoth4s = 1) pcexgcsematpsct = SUM(pcexgcsematpsct, pcexgcseoth4g).
IF (pcexgcseoth4s = 4) pcexgcsetecpsct = SUM(pcexgcsetecpsct, pcexgcseoth4g).
IF (pcexgcseoth4s = 5) pcexgcsehumpsct = SUM(pcexgcsehumpsct, pcexgcseoth4g).
IF (pcexgcseoth4s = 6) pcexgcselanpsct = SUM(pcexgcselanpsct, pcexgcseoth4g).
IF (pcexgcseoth4s = 7) pcexgcsevocpsct = SUM(pcexgcsevocpsct, pcexgcseoth4g).
EXECUTE.

* These point score totals are now complete for all GCSE subject groups.
* so we can sum them to get the overall total GCSE point score.
COMPUTE pcexgcsepsct = SUM(pcexgcsematpsct, pcexgcseengpsct, pcexgcsescipsct, 
  pcexgcsetecpsct, pcexgcsehumpsct, pcexgcselanpsct, pcexgcsevocpsct).
EXECUTE.

* All these point scores have missing values by default.
* Recode missing to 0 if exam results data were collected.
DO IF (pcexdata = 1).
 RECODE pcexgcsematpsct pcexgcseengpsct pcexgcsescipsct pcexgcsetecpsct pcexgcsehumpsct 
   pcexgcselanpsct pcexgcsevocpsct pcexgcsepsct (SYSMIS=0).
END IF.
EXECUTE.
pcexLLCage1/2, pcexLLCdate1/2

See pcbhLLCage1/2, etc above.

pcexothermatgrdm1/2, pcexotherenggrdm1/2, pcexotherscigrdm1/2, pcexothertecgrdm1/2, pcexotherhumgrdm1/2, pcexotherlangrdm1/2, pcexothervocgrdm1/2, pcexothergrdm1/2, pcexothercoregrdm1/2

Mean grades for all qualification types other than GCSE. Each qualification may have grades between 1 and 11, where 4-11 are GCSE-equivalent grades and 1-3 are sub-GCSE Entry Level grades. Hence each of these mean grade variables has values ranging from 1 to 11.
Separate variables are derived in 7 subject groups, plus an overall total, plus the combined core subjects (Maths, English and Science). The derived variables are:
pcexothermatgrdm: Maths
pcexotherenggrdm: English
pcexotherscigrdm: Science
pcexothertecgrdm: technology
pcexotherhumgrdm: humanities
pcexotherlangrdm: languages
pcexothervocgrdm: vocational subjects
pcexothergrdm: all subjects combined
pcexothercoregrdm: core subjects combined.
They are derived from point scores and numbers of qualifications, which are themselves derived variables described elsewhere on this page.

* Mean grades.
* Simply divide the total points score by number of qualifications.
* provide the latter is non-zero.
* Round to the nearest 0.1.
IF (pcexothermatnum > 0) pcexothermatgrdm = RND((pcexothermatpsct / pcexothermatnum), 0.1).
IF (pcexotherengnum > 0) pcexotherenggrdm = RND((pcexotherengpsct / pcexotherengnum), 0.1).
IF (pcexotherscinum > 0) pcexotherscigrdm = RND((pcexotherscipsct / pcexotherscinum), 0.1).
IF (pcexothertecnum > 0) pcexothertecgrdm = RND((pcexothertecpsct / pcexothertecnum), 0.1).
IF (pcexotherhumnum > 0) pcexotherhumgrdm = RND((pcexotherhumpsct / pcexotherhumnum), 0.1).
IF (pcexotherlannum > 0) pcexotherlangrdm = RND((pcexotherlanpsct / pcexotherlannum), 0.1).
IF (pcexothervocnum > 0) pcexothervocgrdm = RND((pcexothervocpsct / pcexothervocnum), 0.1).
IF (pcexothernum > 0) pcexothergrdm = RND((pcexotherpsct / pcexothernum), 0.1).
EXECUTE.
* Core subjects: sum over English, maths and science.
* and require at least 2 of the 3 subjects to be non-missing.
IF (SUM.2(pcexothermatnum, pcexotherengnum, pcexotherscinum) > 0)
    pcexothercoregrdm = RND(((SUM(pcexothermatpsct, pcexotherengpsct, pcexotherscipsct))
     / (SUM(pcexothermatnum, pcexotherengnum, pcexotherscinum))), 0.1).
EXECUTE.
* Each mean grade can in theory have values between 1 and 11.
* 1-3 for entry level grades, 4-11 for GCSE-equivalent grades.
pcexothermatnum1/2, pcexotherengnum1/2, pcexotherscinum1/2, pcexothertecnum1/2, pcexotherhumnum1/2, pcexotherlannum1/2, pcexothervocnum1/2, pcexothernum1/2

Numbers of all qualifications other than GCSEs. Numbers are measured in terms of the equivalents to GCSEs in workload or curriculum time, as specified by the NQF, where a single GCSE result has value 1.
Separate variables are derived in 7 subject groups, plus an overall total. The derived variables are:
pcexothermatnum: Maths
pcexotherengnum: English
pcexotherscinum: Science
pcexothertecnum: technology
pcexotherhumnum: humanities
pcexotherlannum: languages
pcexothervocnum: vocational subjects
pcexothernum: all subjects combined.
They are derived from a range of item variables describing qualifications as recorded in the raw data. Details of the derivation are explained in comments in the syntax below.

* Numbers of qualifications.
* Count these in terms of recognised GCSE-equivalents - the qualifications.
* listed below, up to level 2, had official equivalent ratings at the time of data collection.
* Group into the same 7 subject categories as used for GCSEs.
* Start with 0 count as default value for each subject.
DO IF (pcexdata = 1).
 RECODE pcexothermatnum pcexotherengnum pcexotherscinum pcexothertecnum pcexotherhumnum 
  pcexotherlannum pcexothervocnum (SYSMIS=0).
END IF.
EXECUTE.
* Up to 3 'vocational' results may be recorded: BTEC, ONS or City and Guilds.
* Variables are pcexvocXt (type as above), pcexvocXa (number of equivalents).
* pcexvocXs (subject type 1-7), pcexvocXg (grade, 4-11), where X is 1/2/3.
* Check each of these one by one.
IF (pcexvoc1s = 1) pcexothermatnum = SUM(pcexothermatnum, pcexvoc1a).
IF (pcexvoc2s = 1) pcexothermatnum = SUM(pcexothermatnum, pcexvoc2a).
IF (pcexvoc3s = 1) pcexothermatnum = SUM(pcexothermatnum, pcexvoc3a).
IF (pcexvoc1s = 2) pcexotherengnum = SUM(pcexotherengnum, pcexvoc1a).
IF (pcexvoc2s = 2) pcexotherengnum = SUM(pcexotherengnum, pcexvoc2a).
IF (pcexvoc3s = 2) pcexotherengnum = SUM(pcexotherengnum, pcexvoc3a).
IF (pcexvoc1s = 3) pcexotherscinum = SUM(pcexotherscinum, pcexvoc1a).
IF (pcexvoc2s = 3) pcexotherscinum = SUM(pcexotherscinum, pcexvoc2a).
IF (pcexvoc3s = 3) pcexotherscinum = SUM(pcexotherscinum, pcexvoc3a).
IF (pcexvoc1s = 4) pcexothertecnum = SUM(pcexothertecnum, pcexvoc1a).
IF (pcexvoc2s = 4) pcexothertecnum = SUM(pcexothertecnum, pcexvoc2a).
IF (pcexvoc3s = 4) pcexothertecnum = SUM(pcexothertecnum, pcexvoc3a).
IF (pcexvoc1s = 5) pcexotherhumnum = SUM(pcexotherhumnum, pcexvoc1a).
IF (pcexvoc2s = 5) pcexotherhumnum = SUM(pcexotherhumnum, pcexvoc2a).
IF (pcexvoc3s = 5) pcexotherhumnum = SUM(pcexotherhumnum, pcexvoc3a).
IF (pcexvoc1s = 6) pcexotherlannum = SUM(pcexotherlannum, pcexvoc1a).
IF (pcexvoc2s = 6) pcexotherlannum = SUM(pcexotherlannum, pcexvoc2a).
IF (pcexvoc3s = 6) pcexotherlannum = SUM(pcexotherlannum, pcexvoc3a).
IF (pcexvoc1s = 7) pcexothervocnum = SUM(pcexothervocnum, pcexvoc1a).
IF (pcexvoc2s = 7) pcexothervocnum = SUM(pcexothervocnum, pcexvoc2a).
IF (pcexvoc3s = 7) pcexothervocnum = SUM(pcexothervocnum, pcexvoc3a).
EXECUTE.
* Each NVQ is equivalent to 5 GCSEs, pcexnvqs records the subject.
IF (pcexnvqs = 1) pcexothermatnum = SUM(pcexothermatnum, 5).
IF (pcexnvqs = 2) pcexotherengnum = SUM(pcexotherengnum, 5).
IF (pcexnvqs = 3) pcexotherscinum = SUM(pcexotherscinum, 5).
IF (pcexnvqs = 4) pcexothertecnum = SUM(pcexothertecnum, 5).
IF (pcexnvqs = 5) pcexotherhumnum = SUM(pcexotherhumnum, 5).
IF (pcexnvqs = 6) pcexotherlannum = SUM(pcexotherlannum, 5).
IF (pcexnvqs = 7) pcexothervocnum = SUM(pcexothervocnum, 5).
EXECUTE.
* 'Skills' qualifications: equivalent to half a GCSE.
* Includes Key Skills, Functional Skills, Skills for Life, ALAN and ASDAN qualifications.
* Literacy equates to English.
IF (pcexskillitg > 0) pcexotherengnum = SUM(pcexotherengnum, 0.5 ).
* Numeracy equates to Maths.
IF (pcexskilnumg > 0) pcexothermatnum = SUM(pcexothermatnum, 0.5) .
* For 'others', check the subject variable: 1=ICT (Tech), 2-5 are vocational.
IF (pcexskiloths = 1) pcexothertecnum = SUM(pcexothertecnum, 0.5) .
IF (pcexskiloths > 1) pcexothervocnum = SUM(pcexothervocnum, 0.5) .
EXECUTE.
* Digital applications equates to IT (Tech): AIDA, CIDA, DIDA qualifications.
* Raw variable pcexdigat records the GCSE equivalents.
IF (pcexdigat > 0) pcexothertecnum = SUM(pcexothertecnum, pcexdigat).
EXECUTE.
* Other IT qualifications: ECDL and CLAIT: 1 GCSE equivalent.
IF (pcexothitg > 0) pcexothertecnum = SUM(pcexothertecnum, 1).
EXECUTE.
* Entry level certificates in English, maths and science: 1 GCSE equivalent.
IF (pcexelceng > 0) pcexotherengnum = SUM(pcexotherengnum, 1).
IF (pcexelcmat > 0) pcexothermatnum = SUM(pcexothermatnum, 1).
IF (pcexelcsci > 0) pcexotherscinum = SUM(pcexotherscinum, 1).
EXECUTE.
* Work Life Certificate: 1 GCSE equivalent, vocational subject matter.
IF (pcexwklf > 0) pcexothervocnum = SUM(pcexothervocnum, 1).
EXECUTE.
* Sports/Dance Leadership certificates: half a GCSE equivalent (vocational subjects).
IF (pcexldrg > 0) pcexothervocnum = SUM(pcexothervocnum, 0.5 ).
EXECUTE.
* Miscellaneous 'other' results, not in categories above, have been recorded for some twins.
* Treat each of these as a probable vocational subject.
* and assume each is worth half a GCSE; include up to level 2.
IF (SUM(pcexothentryn, pcexothlevel1n, pcexothlevel2n) > 0) 
    pcexothervocnum = SUM(pcexothervocnum, (0.5 * SUM(pcexothentryn, pcexothlevel1n, pcexothlevel2n))).
EXECUTE.
* Now sum across all subject groups to get a total number.
COMPUTE pcexothernum = SUM(pcexothermatnum, pcexotherengnum, pcexotherscinum, 
  pcexothertecnum, pcexotherhumnum, pcexotherlannum, pcexothervocnum).
EXECUTE.
pcexothermatpsct1/2, pcexotherengpsct1/2, pcexotherscipsct1/2, pcexothertecpsct1/2, pcexotherhumpsct1/2, pcexotherlanpsct1/2, pcexothervocpsct1/2, pcexotherpsct1/2

Point scores for all qualification types other than GCSE. Point scores are derived by multiplying the grade score by the award value (workload) for each recorded qualification, then summing in the appropriate subject group. Each qualification may have a grade value from 1 to 11, and a workload value of 0.5, 1, 2, etc. Hence, after summing over a set of qualifications, the point score may have a wide range of values from 0 upwards (a value of zero indicates no qualifications in the given category).
Separate variables are derived in 7 subject groups, plus an overall total as follows:
pcexothermatpsct: Maths
pcexotherengpsct: English
pcexotherscipsct: Science
pcexothertecpsct: technology
pcexotherhumpsct: humanities
pcexotherlanpsct: languages
pcexothervocpsct: vocational subjects
pcexotherpsct: all subjects combined.
The point scores are derived from a range of item variables in the raw exam results data. The derivations are explained by comments in the syntax below.

* Point scores for other qualifications.
* Include all non-GCSE qualification types.
* separated into the same subject categories as for GCSEs.
* Start with 0 count as default score for each subject.
DO IF (pcexdata = 1).
 RECODE pcexothermatpsct pcexotherengpsct pcexotherscipsct pcexothertecpsct pcexotherhumpsct 
  pcexotherlanpsct pcexothervocpsct (SYSMIS=0).
END IF.
EXECUTE.
* 'Vocational' qualification typs: BTEC, ONS or City and Guilds.
* For point score, multiply pcexvocXa (number of equivalents).
* by pcexvocXg (grade, 4-11), separately for each.
* pcexvocXs (subject type 1-7)
* Repeat for 3 sets of variables (X=1, 2, 3).
IF (pcexvoc1s = 1) pcexothermatpsct = SUM(pcexothermatpsct, (pcexvoc1a * pcexvoc1g)).
IF (pcexvoc2s = 1) pcexothermatpsct = SUM(pcexothermatpsct, (pcexvoc2a * pcexvoc2g)).
IF (pcexvoc3s = 1) pcexothermatpsct = SUM(pcexothermatpsct, (pcexvoc3a * pcexvoc3g)).
IF (pcexvoc1s = 2) pcexotherengpsct = SUM(pcexotherengpsct, (pcexvoc1a * pcexvoc1g)).
IF (pcexvoc2s = 2) pcexotherengpsct = SUM(pcexotherengpsct, (pcexvoc2a * pcexvoc2g)).
IF (pcexvoc3s = 2) pcexotherengpsct = SUM(pcexotherengpsct, (pcexvoc3a * pcexvoc3g)).
IF (pcexvoc1s = 3) pcexotherscipsct = SUM(pcexotherscipsct, (pcexvoc1a * pcexvoc1g)).
IF (pcexvoc2s = 3) pcexotherscipsct = SUM(pcexotherscipsct, (pcexvoc2a * pcexvoc2g)).
IF (pcexvoc3s = 3) pcexotherscipsct = SUM(pcexotherscipsct, (pcexvoc3a * pcexvoc3g)).
IF (pcexvoc1s = 4) pcexothertecpsct = SUM(pcexothertecpsct, (pcexvoc1a * pcexvoc1g)).
IF (pcexvoc2s = 4) pcexothertecpsct = SUM(pcexothertecpsct, (pcexvoc2a * pcexvoc2g)).
IF (pcexvoc3s = 4) pcexothertecpsct = SUM(pcexothertecpsct, (pcexvoc3a * pcexvoc3g)).
IF (pcexvoc1s = 5) pcexotherhumpsct = SUM(pcexotherhumpsct, (pcexvoc1a * pcexvoc1g)).
IF (pcexvoc2s = 5) pcexotherhumpsct = SUM(pcexotherhumpsct, (pcexvoc2a * pcexvoc2g)).
IF (pcexvoc3s = 5) pcexotherhumpsct = SUM(pcexotherhumpsct, (pcexvoc3a * pcexvoc3g)).
IF (pcexvoc1s = 6) pcexotherlanpsct = SUM(pcexotherlanpsct, (pcexvoc1a * pcexvoc1g)).
IF (pcexvoc2s = 6) pcexotherlanpsct = SUM(pcexotherlanpsct, (pcexvoc2a * pcexvoc2g)).
IF (pcexvoc3s = 6) pcexotherlanpsct = SUM(pcexotherlanpsct, (pcexvoc3a * pcexvoc3g)).
IF (pcexvoc1s = 7) pcexothervocpsct = SUM(pcexothervocpsct, (pcexvoc1a * pcexvoc1g)).
IF (pcexvoc2s = 7) pcexothervocpsct = SUM(pcexothervocpsct, (pcexvoc2a * pcexvoc2g)).
IF (pcexvoc3s = 7) pcexothervocpsct = SUM(pcexothervocpsct, (pcexvoc3a * pcexvoc3g)).
EXECUTE.
* Each NVQ is equivalent to 5 GCSEs, pcexnvqs records the subject, pcexnvqg the grade.
IF (pcexnvqs = 1) pcexothermatpsct = SUM(pcexothermatpsct, (5 * pcexnvqg)).
IF (pcexnvqs = 2) pcexotherengpsct = SUM(pcexotherengpsct, (5 * pcexnvqg)).
IF (pcexnvqs = 3) pcexotherscipsct = SUM(pcexotherscipsct, (5 * pcexnvqg)).
IF (pcexnvqs = 4) pcexothertecpsct = SUM(pcexothertecpsct, (5 * pcexnvqg)).
IF (pcexnvqs = 5) pcexotherhumpsct = SUM(pcexotherhumpsct, (5 * pcexnvqg)).
IF (pcexnvqs = 6) pcexotherlanpsct = SUM(pcexotherlanpsct, (5 * pcexnvqg)).
IF (pcexnvqs = 7) pcexothervocpsct = SUM(pcexothervocpsct, (5 * pcexnvqg)).
EXECUTE.
* These types of results are widespread in vocational and techology subjects.
* moderately common in science and humanities.
* but rare in English, maths and languages.

* 'Skills' qualifications: equivalent to half a GCSE.
* so multiply grade variable by 0.5 for the point score.
* Includes Key Skills, Functional Skills, Skills for Life, ALAN and ASDAN qualifications.
* Literacy equates to English.
IF (pcexskillitg > 0) pcexotherengpsct = SUM(pcexotherengpsct, (0.5 * pcexskillitg)) .
* Numeracty equates to Maths.
IF (pcexskilnumg > 0) pcexothermatpsct = SUM(pcexothermatpsct, (0.5 * pcexskilnumg)).
* For 'others', check the subject variable: 1=ICT (Tech), 2-5 are vocational.
IF (pcexskiloths = 1) pcexothertecpsct = SUM(pcexothertecpsct, (0.5 * pcexskilothg)).
IF (pcexskiloths > 1) pcexothervocpsct = SUM(pcexothervocpsct, (0.5 * pcexskilothg)).
EXECUTE.
* Digital applications equates to IT (Tech): AIDA, CIDA, DIDA qualifications.
* Raw variable pcexdigat records the GCSE equivalents - multiply this by.
* the grade variable pcexdigag for the point score.
IF (pcexdigat > 0) pcexothertecpsct = SUM(pcexothertecpsct, (pcexdigat * pcexdigag)).
EXECUTE.
* Other IT qualifications: ECDL and CLAIT: 1 GCSE equivalent.
* so point score equals the grade value pcexothitg.
IF (pcexothitg > 0) pcexothertecpsct = SUM(pcexothertecpsct, pcexothitg).
EXECUTE.
* Entry level certificates in English, maths and science: 1 GCSE equivalent.
* so point score equals the value of the grade variable in each case.
IF (pcexelceng > 0) pcexotherengpsct = SUM(pcexotherengpsct, pcexelceng).
IF (pcexelcmat > 0) pcexothermatpsct = SUM(pcexothermatpsct, pcexelcmat).
IF (pcexelcsci > 0) pcexotherscipsct = SUM(pcexotherscipsct, pcexelcsci).
EXECUTE.
* Work Life Certificate: 1 GCSE equivalent, vocational subject matter.
* so again the point score equals the grade variable value.
IF (pcexwklf > 0) pcexothervocpsct = SUM(pcexothervocpsct, pcexwklf).
EXECUTE.
* Sports/Dance Leadership certificates: half a GCSE equivalent (vocational subjects).
* so point score equals grade variable pcexldrg multiplied by 0.5.
IF (pcexldrg > 0) pcexothervocpsct = SUM(pcexothervocpsct, (0.5 * pcexldrg) ).
EXECUTE.
* Miscellaneous 'other' results, not in categories above, have been recorded for some twins.
* (each variable records the number reported).
* Treat each of these as a probable vocational subject.
* and assume each is worth half a GCSE (multiply grade by 0.5 for point score).
* Exact grades are unknown so assume the lowest available grade at that level.
* which is 1 for entry level, 4 for level 1, 8 for level 2.
IF (pcexothentryn > 0) pcexothervocpsct = SUM(pcexothervocpsct, (pcexothentryn * 0.5 * 1)).
IF (pcexothlevel1n > 0) pcexothervocpsct = SUM(pcexothervocpsct, (pcexothlevel1n * 0.5 * 4)).
IF (pcexothlevel2n > 0) pcexothervocpsct = SUM(pcexothervocpsct, (pcexothlevel2n * 0.5 * 8)).
EXECUTE.

* Now sum across all subject groups to get a total number.
COMPUTE pcexotherpsct = SUM(pcexothermatpsct, pcexotherengpsct, pcexotherscipsct, 
  pcexothertecpsct, pcexotherhumpsct, pcexotherlanpsct, pcexothervocpsct).
EXECUTE.
pcflatm1/2

See pccbatm1/2, etc above.

pcfldtm1/2

See pccbdtm1/2, etc above.

pcg1/2

General cognitive ability composite variable (g).
Derived from adjusted Vocab and Ravens test scores, which are described elsewhere on this page. The exclude1 filter variable is described on the exclusions page.

* Add cognitive variables.
* These variables must be standardised on the non-excluded sample.
* So apply a filter before doing anything else.
USE ALL.
COMPUTE filter_$=(exclude1 = 0).
VARIABLE LABELS filter_$ 'exclude1 = 0 (FILTER)'.
VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'.
FORMATS filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE.

* First standardise the cognitive web test scores.
* Note: use the adjusted Vocab and Ravens scores, not the raw scores.
DESCRIPTIVES
  VARIABLES= pcrvtota pcvctota /SAVE .
  
* Compute G as the mean of the two standardised test scores.
COMPUTE g = MEAN.2(Zpcrvtota, Zpcvctota) .
EXECUTE .
* Cannot really compute verbal and non-verbal scores.
* as these would have only one component each.

* z-standardise the new variables.
DESCRIPTIVES
  VARIABLES= g (pcg) /SAVE .
  
* All the cognitive variables have now been computed on the filtered sample.
* They will have missing values for the exclusions.
* The filter can now be removed.
FILTER OFF.
USE ALL.
EXECUTE .
pcgratm1/2

Gratitude scale.
Total scale derived from all 6 items (reversed where necessary) of the Gratitude measure in child web environment and wellbeing questionnaire part A.
Items have integer values 1-7, and the scale is a mean so it has the same range but with decimal values.
In the syntax below, the scale is computed as variable pcgratm, which is later copied into variables pcgratm1/2 on double entry.

* Total scale (all six items).
COMPUTE pcgratm = MEAN.3(pcqagrat1, pcqagrat2, pcqagrat3r, pcqagrat4, pcqagrat5, pcqagrat6r).
EXECUTE.
pcgritcoim1/2, pcgritperm1/2, pcgritm1/2

See pcambim1/2, etc above.

pchmwkbeht1/2, pchmwkfdbt1/2, pchmwkt1/2

PISA Homework scales.
Total scale and two subscales.
Derived from items of the PISA homework measure in child web environment and wellbeing questionnaire part B.
Each item has integer values 0-3, hence each scale has range from 0 to (3 * number of items) as they are 'totals' computed by multiplying the mean by the number of items.
In the syntax below, the scales are computed as variables pchmwkXXXt, which are later copied into variables pchmwkXXXt1/2 on double entry.

* Behaviour subscale (items 1,2).
COMPUTE pchmwkbeht = 2 * MEAN.1(pcqbhmwk1, pcqbhmwk2r).
EXECUTE.
* Feedback subscale (items 3-5).
COMPUTE pchmwkfdbt = 3 * MEAN.2(pcqbhmwk3, pcqbhmwk4, pcqbhmwk5).
EXECUTE.
* Total scale (all 5 items).
COMPUTE pchmwkt = 5 * MEAN.3(pcqbhmwk1, pcqbhmwk2r, pcqbhmwk3, pcqbhmwk4, pcqbhmwk5).
EXECUTE.
pchopeagm1/2, pchopepam1/2, pchopem1/2

Hopefulness scales.
Total scale (all 6 items) and two subscales (3 items each).
Derived from items of the Hopefulness measure in child web environment and wellbeing questionnaire part A.
Items have integer values 1-6, and the scales are means so have the same range but with decimal values.
In the syntax below, the scales are computed as variables pchopeXXm, which are later copied into variables pchopeXXm1/2 on double entry.

*Agency subscale (items 1, 3, 5).
COMPUTE pchopeagm = MEAN.2(pcqahopef1, pcqahopef3, pcqahopef5).
EXECUTE .
*Pathways subscale (items 2, 4, 6).
COMPUTE pchopepam = MEAN.2(pcqahopef2, pcqahopef4, pcqahopef6).
EXECUTE .
*Total scale (all six items).
COMPUTE pchopem = MEAN.3(pcqahopef1, pcqahopef2,
 pcqahopef3, pcqahopef4, pcqahopef5, pcqahopef6).
EXECUTE .
pcl2age1/2

See pcbhage1/2, etc above.

pcl2alco21/2

See pcbhalco21/2, pcl2alco21/2 above.

pcl2anhdt1/2

See pcbhanhdt1/2, etc above.

pcl2capst1/2

See pcbhcapst1/2, etc above.

pcl2casit1/2

See pcbhcasit1/2, etc above.

pcl2cgdst1/2

See pcbhcgdst1/2, etc above.

pcl2grndt1/2

See pcbhgrndt1/2, etc above.

pcl2hclhft1/2

HCL high feelings scale.
Total scale derived from the 15 yes/no questions about behaviour when feeling high, from the HCL measure in the child leap-2 study booklet.
Each item has values 0=no 1=yes, and the scale is a total so it also has values in the range 0-15 including decimal values.
The scale is computed as pcl2hclhft in the syntax below, and later copied to variables pcl2hclhft1/2 on double entry.

* Total 'feelings when on a high' scale from 15 items 3-17 (all coded 0/1).
COMPUTE pcl2hclhft = 15 * MEAN.8(pcl2hcl03, pcl2hcl04, pcl2hcl05, pcl2hcl06,
 pcl2hcl07, pcl2hcl08, pcl2hcl09, pcl2hcl10, pcl2hcl11, pcl2hcl12, pcl2hcl13,
 pcl2hcl14, pcl2hcl15).
EXECUTE.
pcl2hsct1/2, pcl2hsceoet1/2, pcl2hscaest1/2, pcl2hsclstt1/2

Total scale and subscales derived from the 12 items of the HSC (Highly Sensitive Child) measure in the twin Leap-2 booklet.
pcl2hsct1/2: overall total scale from all 12 items.
pcl2hsceoet1/2: ease of excitation subscale from 5 items.
pcl2hscaest1/2: aesthetic sensitivity subscale from 4 items.
pcl2hsclstt1/2: low sensory threshold subscale from 3 items.
Items have integer values 0 to 6. Each scale is derived as a mean scaled up as if it were a total, hence having values ranging from 0 up to six times the number of items included.

* HSC.
* Included in twin Leap-2 only.

* Ease of Excitation subscale: 5 items.
COMPUTE pcl2hsceoet = 5 * MEAN.3(pcl2hsc04, pcl2hsc06, pcl2hsc08, pcl2hsc09, pcl2hsc12).
* Aesthetic Sensitivity subscale: 4 items.
COMPUTE pcl2hscaest = 4 * MEAN.2(pcl2hsc01, pcl2hsc03, pcl2hsc05, pcl2hsc10).
* Low Sensory Threshold subscale: 3 items.
COMPUTE pcl2hsclstt = 3 * MEAN.2(pcl2hsc02, pcl2hsc07, pcl2hsc11).
EXECUTE.

* total scale from all 12 items.
COMPUTE pcl2hsct = 12 * MEAN.6(pcl2hsc01, pcl2hsc02, 
    pcl2hsc03, pcl2hsc04, pcl2hsc05, pcl2hsc06, pcl2hsc07, 
    pcl2hsc08, pcl2hsc09, pcl2hsc10, pcl2hsc11, pcl2hsc12).
EXECUTE.
pcl2lfevnat1/2, pcl2lfevnnt1/2, pcl2lfevpat1/2, pcl2lfevpnt1/2

See pcbhlfevnat1/2, etc above.

pcl2mfqt1/2

See pcbhmfqt1/2, etc above.

pcl2LLCage1/2, pcl2LLCdate1/2

See pcbhLLCage1/2, etc above.

pcl2plikt1/2

PLIKS total scale.
Total scale derived from all 10 compulsory (non-branched) items of the PLIKS measure in the twin self-report LEAP-2 booklet.
Items have integer values 0-2, hence the scale has values ranging from 0 to 20.

* PLIKS.
* Included in twin Leap-2 only.
* total scale, from all 10 compulsory, non-branched items (all coded 0/1/2).
COMPUTE pcl2plikt = 10 * MEAN.5(pcl2plik01, pcl2plik05, pcl2plik08, pcl2plik11, 
    pcl2plik16, pcl2plik20, pcl2plik24a, pcl2plik24b, pcl2plik24c, pcl2plik27).
EXECUTE.
pcl2prndt1/2

See pcbhprndt1/2, etc above.

pcl2tepst1/2

See pcbhtepst1/2, etc above.

pclotrm1/2

LOT-R Optimism scale.
Total scale derived from all 6 items (reversed where necessary) of the LOT-R Optimism measure in child web environment and wellbeing questionnaire part D.
Items have integer values 1-5, and the scale is a mean so it has the same range but with decimal values.
In the syntax below, the scale is computed as variable pclotrm, which is later copied into variables pclotrm1/2 on double entry.

* Total scale (all 6 items).
COMPUTE pclotrm = MEAN.3(pcqdlotr1, pcqdlotr2r, pcqdlotr3, pcqdlotr4r, pcqdlotr5r, pcqdlotr6).
EXECUTE.
pclsfamm1/2, pclsfrnm1/2, pclslvem1/2, pclsschm1/2, pclsslfm1/2, pclsm1/2

Life Satisfaction scales.
Total scale and five subscales.
Derived from items (reversed where necessary) of the Life Satisfaction measure in child web environment and wellbeing questionnaire part A.
Items have integer values 1-6, and the scales are means so have the same range but with decimal values.
In the syntax below, the scales are computed as variables pclsXXXm, which are later copied into variables pclsXXXm1/2 on double entry.

* Create 5 subscales and total scale as means (do not scale up by multiplying).
*Family satisfaction mean (items 5, 12, 13, 14).
COMPUTE pclsfamm = MEAN.2(pcqalifs05, pcqalifs12, pcqalifs13, pcqalifs14) .
EXECUTE .

*Friends satisfaction mean (items 2, 7, 10, 16, 19).
COMPUTE pclsfrnm = MEAN.3(pcqalifs02r, pcqalifs07, pcqalifs10, pcqalifs16r, pcqalifs19) .
EXECUTE .

*School satisfaction mean (items 4, 6, 15, 17).
COMPUTE pclsschm = MEAN.2(pcqalifs04, pcqalifs06r, pcqalifs15, pcqalifs17) .
EXECUTE .

*Living environment satisfaction mean (items 9, 18, 20, 21).
COMPUTE pclslvem = MEAN.2(pcqalifs09, pcqalifs18r, pcqalifs20r, pcqalifs21) .
EXECUTE .

*Self satisfaction mean (items 1, 3, 8, 11).
COMPUTE pclsslfm = MEAN.2(pcqalifs01, pcqalifs03, pcqalifs08, pcqalifs11) .
EXECUTE .

*Total Scale (all 21 items).
COMPUTE pclsm = MEAN.11(pcqalifs01, pcqalifs02r, pcqalifs03, pcqalifs04, pcqalifs05, pcqalifs06r, 
    pcqalifs07, pcqalifs08, pcqalifs09, pcqalifs10, pcqalifs11, pcqalifs12, pcqalifs13, pcqalifs14, 
    pcqalifs15, pcqalifs16r, pcqalifs17, pcqalifs18r, pcqalifs19, pcqalifs20r, pcqalifs21) .
EXECUTE .
pcmainm1/2

PISA Maths Interest scale.
Total scale derived from all 3 items of the PISA Maths Interest measure in child web environment and wellbeing questionnaire part B.
Items have integer values 1-4, and the scale is a mean so it has the same range but with decimal values.
In the syntax below, the scale is computed as variable pcmainm, which is later copied into variables pcmainm1/2 on double entry.

* Total scale (all 3 items).
COMPUTE pcmainm = MEAN.2(pcqbmain1, pcqbmain2, pcqbmain3).
EXECUTE.
pcmaset1/2

PISA Maths Self-Efficacy scale.
Total scale derived from all 8 items of the PISA maths self-efficacy measure in child web environment and wellbeing questionnaire part B.
Each item has integer values 0-3, hence the scale has range 0-24 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcmaset, which is later copied into variables pcmaset1/2 on double entry.

* Total scale (all 8 items).
COMPUTE pcmaset = 8 * MEAN.4(pcqbmase1, pcqbmase2, pcqbmase3,
 pcqbmase4, pcqbmase5, pcqbmase6, pcqbmase7, pcqbmase8).
EXECUTE.
pcmatmt1/2

PISA Time Spent on Maths scale.
Total scale derived from all 3 items of the PISA Time Spent on Maths measure in child web environment and wellbeing questionnaire part B.
Each item has integer values 0-4, hence the scale has range 0-12 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcmatmt, which is later copied into variables pcmatmt1/2 on double entry.

* Total scale (all 3 items).
COMPUTE pcmatmt = 3 * MEAN.2(pcqbmatm1, pcqbmatm2, pcqbmatm3).
EXECUTE.
pcnlatm1/2

See pccbatm1/2, etc above.

pcnldtm1/2

See pccbdtm1/2, etc above.

pcnsatm1/2

See pccbatm1/2, etc above.

pcnswebcor1/2, pcnswebunc1/2

These are Weber Fraction scores derived for the Dot Task (Number Sense web test).
pcnswebcor1/2 is the 'corrected' version, while pcnswebunc1/2 is the 'uncorrected' version. These Weber Fractions are derived externally using an R script provided by the originator of the test; the variables are then imported into the dataset as if they were item variables. The script is not recorded here.

pcpacom1/2, pcpamom1/2

Parental control (pcpacom) and monitoring (pcpamom) scales.
Derived from items of the parental monitoring and control measures in child web environment and wellbeing questionnaire part C.
Parental control items have integer values 1-5, while parental monitoring items have integer values 1-4. The respective scales are means, hence they have the same respective ranges but with decimal values.
In the syntax below, the scales are computed as variables pcpacom and pcpamom, which are later copied into variables pcpacom1/2 and pcpamom1/2 on double entry.

* Parental control total (all 8 items).
COMPUTE pcpacom = MEAN.4(pcqcpaco1, pcqcpaco2, pcqcpaco3, pcqcpaco4,
 pcqcpaco5, pcqcpaco6, pcqcpaco7, pcqcpaco8).
EXECUTE.
*Parental monitoring total (all 6 items).
COMPUTE pcpamom = MEAN.3(pcqcpamo1, pcqcpamo2, pcqcpamo3,
 pcqcpamo4, pcqcpamo5, pcqcpamo6).
EXECUTE.
pcpersagrm1/2, pcpersconm1/2, pcpersextm1/2, pcpersneum1/2, pcpersopem1/2

Personality scales.
Five subscales, each derived from 6 items.
Derived from items of the personality measure in child web environment and wellbeing questionnaire part D.
Items have integer values 1-5, and the scales are means so have the same range but with decimal values.
In the syntax below, the scales are computed as variables pcpersXXXm, which are later copied into variables pcpersXXXm1/2 on double entry.

* 5 subscales with 6 items in each.
* Neuroticism subscale (items 1-6).
COMPUTE pcpersneum = MEAN.3(pcqdpers01, pcqdpers02, pcqdpers03,
 pcqdpers04, pcqdpers05, pcqdpers06).
EXECUTE.
* Extraversion subscale (items 7-12).
COMPUTE pcpersextm = MEAN.3(pcqdpers07, pcqdpers08, pcqdpers09,
 pcqdpers10, pcqdpers11, pcqdpers12).
EXECUTE.
* Openness subscale (items 13-18).
COMPUTE pcpersopem = MEAN.3(pcqdpers13, pcqdpers14, pcqdpers15,
 pcqdpers16, pcqdpers17, pcqdpers18).
EXECUTE.
* Agreeableness subscale (items 19-24).
COMPUTE pcpersagrm = MEAN.3(pcqdpers19, pcqdpers20, pcqdpers21,
 pcqdpers22, pcqdpers23, pcqdpers24).
EXECUTE.
* Conscientiousness subscale (items 25-30).
COMPUTE pcpersconm = MEAN.3(pcqdpers25, pcqdpers26, pcqdpers27,
 pcqdpers28, pcqdpers29, pcqdpers30).
EXECUTE.
pcpevit1/2

Peer Victimisation scale.
Total scale derived from all 6 items of the Peer Victimisation measure in child web environment and wellbeing questionnaire part B.
Each item has integer values 0-2, hence the scale has range 0-12 as it a 'total' computed by multiplying the mean by the number of items.
In the syntax below, the scale is computed as variable pcpevit, which is later copied into variables pcpevit1/2 on double entry.

* Total scale (all 6 items).
COMPUTE pcpevit = 6 * MEAN.3(pcqbpevi1, pcqbpevi2,
 pcqbpevi3, pcqbpevi4, pcqbpevi5, pcqbpevi6).
EXECUTE.
pcpsatm1/2

See pccbatm1/2, etc above.

pcpsdtm1/2

See pccbdtm1/2, etc above.

pcpubm1/2

Puberty scale, derived from the self-reported puberty items in environment and wellbeing web questionnaire part D.
Requires preliminary recoding into temporary variables, to ensure consistent value ranges (1 to 4) for all component items.
The scale is a mean, so it has decimal values in the range 1 to 4.
Note that different sets of items are used to compute the scale for male and female twins.
The scale is computed as pcpubm in the syntax below, and later copied to variables pcpubm1/2 on double entry.

* Item 7 only has values 1=yes and 2=no.
* Recode these to 1=no and 4=yes so the range of values is comparable with the other items.
RECODE pcqdpub07 
 (1=4) (2=1) (ELSE=SYSMIS)
INTO pub7 .
EXECUTE.

* Items 1-3 are common to both sexes, but items 6-7 are for girls and items 9-10 are for boys.
* Use MEAN (not MEAN.X) so a minimum of only one of the five items is required for the scale.
DO IF (sex1 = 0).
  COMPUTE pcpubm = MEAN(pcqdpub01, pcqdpub02, pcqdpub03, pcqdpub06, pub7).
ELSE IF (sex1 = 1).
  COMPUTE pcpubm = MEAN(pcqdpub01, pcqdpub02, pcqdpub03, pcqdpub09, pcqdpub10).
END IF.
EXECUTE.
pcpvatm1/2

See pccbatm1/2, etc above.

pcpvdtm1/2

See pccbdtm1/2, etc above.

pcqattt1/2, pcqbttt1/2, pcqcttt1/2, pcqdttt1/2

Total time, in minutes, for each of the 4 web questionnaires to be completed.
For these 4 environment and wellbeing web questionnaires, unlike the cognitive web tests, no 'time elapsed' item variable exists; the time can instead be calculated from the start and end dates/times, provided that the questionnaire was completed in a single session on a single day. These date and time variables are not retained in the dataset.

* For the 4 web questionnaires, time-elapsed was not measured.
* But for questionnaires completed in 1 session (on the same day).
* can work out time by subtracting start time from end time.
COMPUTE pcqadays = DATEDIFF(pcqaendt,pcqastdt,'days') .
COMPUTE pcqbdays = DATEDIFF(pcqbendt,pcqbstdt,'days') .
COMPUTE pcqcdays = DATEDIFF(pcqcendt,pcqcstdt,'days') .
COMPUTE pcqddays = DATEDIFF(pcqdendt,pcqdstdt,'days') .
EXECUTE .
DO IF (pcqadays = 0 & pcqasess = 1).
  COMPUTE pcqattt = (1/60) * DATEDIFF(pcqaentm,pcqasttm,'seconds') .
END IF.
DO IF (pcqbdays = 0 & pcqbsess = 1).
  COMPUTE pcqbttt = (1/60) * DATEDIFF(pcqbentm,pcqbsttm,'seconds') .
END IF.
DO IF (pcqcdays = 0 & pcqcsess = 1).
  COMPUTE pcqcttt = (1/60) * DATEDIFF(pcqcentm,pcqcsttm,'seconds') .
END IF.
DO IF (pcqddays = 0 & pcqdsess = 1).
  COMPUTE pcqdttt = (1/60) * DATEDIFF(pcqdentm,pcqdsttm,'seconds') .
END IF.
EXECUTE.
pcqdpub081/2

Age at onset of menstruation (integer number of months), to replace the raw item containing a reported year and month (in numeric format yyyymm). Derived using the twin birth date (aonsdob). The raw menstruation date and the twin birth date are not retained in the dataset for reasons of potential identifiability.

* Replace the raw menstruation date (yyyymm) with a derived age.
* This avoids retention of dates that could aid identifiability.
* First rename the raw variable.
RENAME VARIABLES (pcqdpub08 = pub08yyyymm).
* Now extract the year and month.
COMPUTE pub08yyyy = TRUNC(pub08yyyymm / 100).
COMPUTE pub08mm = MOD(pub08yyyymm, 100).
EXECUTE.
* Note that month number is coded 0 where it was missing in the raw data (date YYYY00).
* get year and month of twin birth.
COMPUTE aonsby = XDATE.YEAR(aonsdob).
COMPUTE aonsbm = XDATE.MONTH(aonsdob).
EXECUTE.
* Now derive the age in months (using original variable name pcqdpub08).
NUMERIC pcqdpub08 (F3.0).
VARIABLE LEVEL pcqdpub08 (SCALE).
* if month is missing, just use the year.
IF (pub08mm = 0) pcqdpub08 = (pub08yyyy - aonsby) * 12.
EXECUTE.
* otherwise include months in calculation.
IF (pub08mm > 0) pcqdpub08 = (12 * (pub08yyyy - aonsby)) + (pub08mm - aonsbm).
EXECUTE.
pcrtatm1/2

See pccbatm1/2, etc above.

pcrvatm1/2

See pccbatm1/2, etc above.

pcrvdtm1/2

See pccbdtm1/2, etc above.

pcrvtota1/2

Adjusted score for the Ravens web test.
This incorporates a correction for twins who finished any subtest early due to the discontinue rule.
Start by computing temporary adjusted item score variables: where the item was discontinued, replace the default zero score with the 'chance' score for that item, namely the mean score that would be gained by selecting an answer at random.
The adjusted test score is then the sum of these adjusted item scores.
Computed as pcrvtota in the syntax below, which is copied to variables pcrvtota1/2 on double entry.

* Compute the adjusted item scores in new temporary variables.
* Copy existing item scores, but replace missing item scores (due to discontinue).
* with chance scores - these are always 1/8=0.125 as there are always 8 possible responses.
* Discontinue only applies after the first three items in each subtest.
* so do not compute adjusted scores for the first three in each subtest.
* Discontinued item answers are coded as -2. 
COMPUTE pcrvc07sca = pcrvc07sc.
COMPUTE pcrvc09sca = pcrvc09sc.
COMPUTE pcrvc11sca = pcrvc11sc.
COMPUTE pcrvd07sca = pcrvd07sc.
COMPUTE pcrvd09sca = pcrvd09sc.
COMPUTE pcrvd11sca = pcrvd11sc.
COMPUTE pcrve07sca = pcrve07sc.
COMPUTE pcrve09sca = pcrve09sc.
COMPUTE pcrve11sca = pcrve11sc.
COMPUTE pcrvf04sca = pcrvf04sc.
COMPUTE pcrvf05sca = pcrvf05sc.
COMPUTE pcrvf06sca = pcrvf06sc.
COMPUTE pcrvf07sca = pcrvf07sc.
COMPUTE pcrvf08sca = pcrvf08sc.
COMPUTE pcrvf09sca = pcrvf09sc.
COMPUTE pcrvf10sca = pcrvf10sc.
COMPUTE pcrvf11sca = pcrvf11sc.
COMPUTE pcrvf12sca = pcrvf12sc.
EXECUTE.
IF (pcrvc07an = -2) pcrvc07sca = 0.125 .
IF (pcrvc09an = -2) pcrvc09sca = 0.125 .
IF (pcrvc11an = -2) pcrvc11sca = 0.125 .
IF (pcrvd07an = -2) pcrvd07sca = 0.125 .
IF (pcrvd09an = -2) pcrvd09sca = 0.125 .
IF (pcrvd11an = -2) pcrvd11sca = 0.125 .
IF (pcrve07an = -2) pcrve07sca = 0.125 .
IF (pcrve09an = -2) pcrve09sca = 0.125 .
IF (pcrve11an = -2) pcrve11sca = 0.125 .
IF (pcrvf04an = -2) pcrvf04sca = 0.125 .
IF (pcrvf05an = -2) pcrvf05sca = 0.125 .
IF (pcrvf06an = -2) pcrvf06sca = 0.125 .
IF (pcrvf07an = -2) pcrvf07sca = 0.125 .
IF (pcrvf08an = -2) pcrvf08sca = 0.125 .
IF (pcrvf09an = -2) pcrvf09sca = 0.125 .
IF (pcrvf10an = -2) pcrvf10sca = 0.125 .
IF (pcrvf11an = -2) pcrvf11sca = 0.125 .
IF (pcrvf12an = -2) pcrvf12sca = 0.125 .
EXECUTE.

* The adjusted test score is now the sum of these adjusted item scores.
* plus the unadjusted item scores for the first three items in each subtest.
* Only compute the adjusted test score for twins with Ravens data.
DO IF (pcrvdata = 1).
 COMPUTE pcrvtota = SUM(pcrvc01sc, pcrvc03sc, pcrvc05sc,
 pcrvc07sca, pcrvc09sca, pcrvc11sca, pcrvd01sc, pcrvd03sc, pcrvd05sc,
 pcrvd07sca, pcrvd09sca, pcrvd11sca, pcrve01sc, pcrve03sc, pcrve05sc,
 pcrve07sca, pcrve09sca, pcrve11sca, pcrvf01sc, pcrvf02sc, pcrvf03sc,
 pcrvf04sca, pcrvf05sca, pcrvf06sca, pcrvf07sca, pcrvf08sca, pcrvf09sca,
 pcrvf10sca, pcrvf11sca, pcrvf12sca).
END IF.
EXECUTE.
pcscencrsm1/2, pcscenfagm1/2, pcscenfslm1/2, pcscenpslm1/2, pcscentsrm1/2, pcscenm1/2

School Engagement scales.
Total scale and five subscales.
Derived from items of the school engagement measure in child web environment and wellbeing questionnaire part B.
Items have integer values 1-4, and the scales are means so have the same range but with decimal values.
In the syntax below, the scales are computed as variables pcscenXXXm, which are later copied into variables pcscenXXXm1/2 on double entry.

*19 items, 5 subscales - no need to reverse any items. 

* Teacher-Student Relations subscale (items 1-6).
COMPUTE pcscentsrm = MEAN.3(pcqbscen01, pcqbscen02,
 pcqbscen03, pcqbscen04, pcqbscen05, pcqbscen06).
EXECUTE.
* Control/Relevance of school work subscale (items 7-10).
COMPUTE pcscencrsm = MEAN.2(pcqbscen07, pcqbscen08, pcqbscen09, pcqbscen10).
EXECUTE.
* Peer Support for learning subscale (items 11-13).
COMPUTE pcscenpslm = MEAN.2(pcqbscen11, pcqbscen12, pcqbscen13).
EXECUTE.
* Future Aspirations/Goals subscale (items 14-16).
COMPUTE pcscenfagm = MEAN.2(pcqbscen14, pcqbscen15, pcqbscen16).
EXECUTE.
* Family Support for learning subscale (items 17-19).
COMPUTE pcscenfslm = MEAN.2(pcqbscen17, pcqbscen18, pcqbscen19).
EXECUTE.
* Total scale (all 19 items).
COMPUTE pcscenm = MEAN.10(pcqbscen01, pcqbscen02, pcqbscen03,
 pcqbscen04, pcqbscen05, pcqbscen06, pcqbscen07, pcqbscen08, pcqbscen09,
 pcqbscen10, pcqbscen11, pcqbscen12, pcqbscen13, pcqbscen14, pcqbscen15,
 pcqbscen16, pcqbscen17, pcqbscen18, pcqbscen19).
EXECUTE.
pcsecom1/2

Academic self-concept scale.
Derived from items (reversed where necessary) of the academic self-concept measure in child web environment and wellbeing questionnaire part D.
Items have integer values 1-5, and the scale is a mean so it has the same range but with decimal values.
In the syntax below, the scale is computed as variable pcsecom, which is later copied into variables pcsecom1/2 on double entry.

* Total scale.
COMPUTE pcsecom = MEAN.5(pcqdseco01, pcqdseco02, pcqdseco03, pcqdseco04r, pcqdseco05,
 pcqdseco06, pcqdseco07r, pcqdseco08, pcqdseco09r, pcqdseco10).
EXECUTE.
pcshsm1/2

See pcbhshsm1/2, pcshsm1/2 above.

pcunatm1/2

See pccbatm1/2, etc above.

pcundtm1/2

See pccbdtm1/2, etc above.

pcuntota1/2

Adjusted score for the Understanding Number web test.
This incorporates a correction for twins who finished the test early due to the discontinue rule.
Start by computing temporary adjusted item score variables: where the item was discontinued, replace the default zero score with the 'chance' score for that item, namely the mean score that would be gained by selecting an answer at random.
The adjusted test score is then the sum of these adjusted item scores.
Computed as pcuntota in the syntax below, which is copied to variables pcuntota1/2 on double entry.

* Compute the adjusted item scores in new temporary variables.
* Copy existing item scores, but replace missing item scores (due to discontinue).
* Discontinue after 2 consecutive incorrect responses after initial branching.
* so no need in branch items 7/8 or in lowest items 1/2.
* Discontinued items are flagged using value -2 (or string '-2') in the answer variables.

* Chance scores vary from item to item due to different response formats.
* Where twins have to type in numeric answers, the chance score is effectively zero.
* So chance scores only apply where twins can click on multiple choices.
* hence are only used in the items listed below.
COMPUTE pcun05sca = pcun05sc.
COMPUTE pcun09sca = pcun09sc.
COMPUTE pcun10sca = pcun10sc.
COMPUTE pcun13sca = pcun13sc.
COMPUTE pcun15sca = pcun15sc.
COMPUTE pcun18sca = pcun18sc.
EXECUTE.
IF (pcun05an = -2) pcun05sca = 0.2 .
IF (pcun09an = -2) pcun09sca = 0.2 .
IF (pcun10an = '-2') pcun10sca = 0.067 .
IF (pcun13an = -2) pcun13sca = 0.2 .
IF (pcun15an = -2) pcun15sca = 0.167 .
IF (pcun18an = -2) pcun18sca = 0.25 .
EXECUTE.

* The adjusted test score is now the sum of these adjusted item scores.
* plus the unadjusted item scores for the remaining items.
* Only compute the adjusted test score for twins with Understanding Number data.
DO IF (pcundata = 1).
 COMPUTE pcuntota = SUM(pcun01sc, pcun02sc, pcun03sc, pcun04sc, pcun05sca,
 pcun06sc, pcun07sc, pcun08sc, pcun09sca, pcun10sca, pcun11sc, pcun12sc,
 pcun13sca, pcun14sc, pcun15sca, pcun16sc, pcun17sc, pcun18sca).
END IF.
EXECUTE.
pcvcatm1/2

See pccbatm1/2, etc above.

pcvcdtm1/2

See pccbdtm1/2, etc above.

pcvctota1/2

Adjusted score for the Mill Hill Vocabulary web test.
This incorporates a correction for twins who finished the test early due to the discontinue rule.
Start by computing temporary adjusted item score variables: where the item was discontinued, replace the default zero score with the 'chance' score for that item, namely the mean score that would be gained by selecting an answer at random.
The adjusted test score is then the sum of these adjusted item scores.
Computed as pcvctota in the syntax below, which is copied to variables pcvctota1/2 on double entry.

* Compute the adjusted item scores in new temporary variables.
* Copy existing item scores, but replace missing item scores (due to discontinue).
* Each item has 6 possible responses, so chance score is 1/6=0.167.
* Discontinue after 7 consecutive incorrect responses, so no need for items 1-7.
* Discontinued items are flagged using value -2 in the answer variables.
COMPUTE pcvc08sca = pcvc08sc.
COMPUTE pcvc09sca = pcvc09sc.
COMPUTE pcvc10sca = pcvc10sc.
COMPUTE pcvc11sca = pcvc11sc.
COMPUTE pcvc12sca = pcvc12sc.
COMPUTE pcvc13sca = pcvc13sc.
COMPUTE pcvc14sca = pcvc14sc.
COMPUTE pcvc15sca = pcvc15sc.
COMPUTE pcvc16sca = pcvc16sc.
COMPUTE pcvc17sca = pcvc17sc.
COMPUTE pcvc18sca = pcvc18sc.
COMPUTE pcvc19sca = pcvc19sc.
COMPUTE pcvc20sca = pcvc20sc.
COMPUTE pcvc21sca = pcvc21sc.
COMPUTE pcvc22sca = pcvc22sc.
COMPUTE pcvc23sca = pcvc23sc.
COMPUTE pcvc24sca = pcvc24sc.
COMPUTE pcvc25sca = pcvc25sc.
COMPUTE pcvc26sca = pcvc26sc.
COMPUTE pcvc27sca = pcvc27sc.
COMPUTE pcvc28sca = pcvc28sc.
COMPUTE pcvc29sca = pcvc29sc.
COMPUTE pcvc30sca = pcvc30sc.
COMPUTE pcvc31sca = pcvc31sc.
COMPUTE pcvc32sca = pcvc32sc.
COMPUTE pcvc33sca = pcvc33sc.
EXECUTE.
IF (pcvc08an = -2) pcvc08sca = 0.167 .
IF (pcvc09an = -2) pcvc09sca = 0.167 .
IF (pcvc10an = -2) pcvc10sca = 0.167 .
IF (pcvc11an = -2) pcvc11sca = 0.167 .
IF (pcvc12an = -2) pcvc12sca = 0.167 .
IF (pcvc13an = -2) pcvc13sca = 0.167 .
IF (pcvc14an = -2) pcvc14sca = 0.167 .
IF (pcvc15an = -2) pcvc15sca = 0.167 .
IF (pcvc16an = -2) pcvc16sca = 0.167 .
IF (pcvc17an = -2) pcvc17sca = 0.167 .
IF (pcvc18an = -2) pcvc18sca = 0.167 .
IF (pcvc19an = -2) pcvc19sca = 0.167 .
IF (pcvc20an = -2) pcvc20sca = 0.167 .
IF (pcvc21an = -2) pcvc21sca = 0.167 .
IF (pcvc22an = -2) pcvc22sca = 0.167 .
IF (pcvc23an = -2) pcvc23sca = 0.167 .
IF (pcvc24an = -2) pcvc24sca = 0.167 .
IF (pcvc25an = -2) pcvc25sca = 0.167 .
IF (pcvc26an = -2) pcvc26sca = 0.167 .
IF (pcvc27an = -2) pcvc27sca = 0.167 .
IF (pcvc28an = -2) pcvc28sca = 0.167 .
IF (pcvc29an = -2) pcvc29sca = 0.167 .
IF (pcvc30an = -2) pcvc30sca = 0.167 .
IF (pcvc31an = -2) pcvc31sca = 0.167 .
IF (pcvc32an = -2) pcvc32sca = 0.167 .
IF (pcvc33an = -2) pcvc33sca = 0.167 .
EXECUTE.

* The adjusted test score is now the sum of these adjusted item scores.
* plus the unadjusted item scores for the first seven items.
* Only compute the adjusted test score for twins with Vocabulary data.
DO IF (pcvcdata = 1).
 COMPUTE pcvctota = SUM(pcvc01sc, pcvc02sc, pcvc03sc, pcvc04sc, pcvc05sc,
 pcvc06sc, pcvc07sc, pcvc08sca, pcvc09sca, pcvc10sca, pcvc11sca, pcvc12sca,
 pcvc13sca, pcvc14sca, pcvc15sca, pcvc16sca, pcvc17sca, pcvc18sca, pcvc19sca,
 pcvc20sca, pcvc21sca, pcvc22sca, pcvc23sca, pcvc24sca, pcvc25sca, pcvc26sca,
 pcvc27sca, pcvc28sca, pcvc29sca, pcvc30sca, pcvc31sca, pcvc32sca, pcvc33sca).
END IF.
EXECUTE.
pcwbpsym1/2, pcwbsubm1/2

Wellbeing composites derived from multiple measures. Most component measures are from the web study, and the composites are only available for cohorts 1 and 2.
pcwbpsym1/2: Psychological Wellbeing composite, derived from Grit, Ambition, Curiosity and Hopefulness measures.
pcwbsubm1/2: Subjective Wellbeing composite, derived from Gratitude, Optimism, SHS and Life Satisfaction measures.
Each composite is derived as an equally-weighted mean of its four components, and rescaled to decimal values between 0 and 1.

* Wellbeing composites.
* Two composites, each derived from 4 wellbeing measures.
* Suggested by Elham Assary after factor analysis.
* Components have different value ranges (1-5, 1-6 or 1-7).
* so rescale them all to range 0-1 for equal weighting.
* then derive a mean.
* Largely based on web data (6 of 8 components) so composites.
* will be derived only for cohort 1/2 twins having web data.
* Subjective Wellbeing: from Gratitude, Optimism, Life Satisfaction and SHS.
* Optimism has values 1-5, the other three have values 1-7.
* Rescale all to range 0-1 then derive equally-weighted mean.
COMPUTE pcwbsubm = MEAN.3(((pclotrm - 1) / 5),(( pcgratm - 1) / 7), 
    ((pcbhlssm - 1) / 7), ((pcbhshsm - 1) / 7)).
EXECUTE.
* Psychological Wellbeing: from Grit (1-5), Ambition (1-5).
* Hopefulness (1-6) and Curiosity (1.7).
COMPUTE pcwbpsym = MEAN.3(((pcgritm - 1) / 5), ((pcambim - 1) / 5),
    ((pchopem - 1) / 6), ((pccurim - 1) / 7)).
EXECUTE.
* (Use of MEAN.3 in the former case ensures that at least one web measure.
* must be non-missing, so the composite is not derived if only the two.
* booklet measures are present; hence the composite is only derived for cohorts 1 and 2).
pcwebage1/2

See pcbhage1/2, etc above.

pcwebdata1/2

Flag variables showing the presence or absence of twin web data.
Derived from item flag variables for the 16 separate activities- twin web data exists if test data is present for at least one of these activities.
This was derived after the syntax for excluding twins in each web test, where test data flags were recoded from 1 to 0 in some cases.

* Now data have been excluded, we can check whether twin web data exists.
COMPUTE pcwebdata = 0.
EXECUTE.
IF (SUM(pcqadata, pcqbdata, pcqcdata, pcqddata, pcdndata, pcnldata, pcnsdata,
   pcpvdata, pcrtdata, pccbdata, pcundata, pcrvdata, pcvcdata, pcyndata, 
   pcfldata, pcpsdata) > 0) pcwebdata = 1.
EXECUTE.
pcwebLLCage1/2, pcwebLLCdate1/2

See pcbhLLCage1/2, etc above.

pcynatm1/2

See pccbatm1/2, etc above.

ppbhage

See pcbhage1/2, etc above.

ppbhanxt1/2, ppbhanxshyt1/2, ppbhanxocbt1/2, ppbhanxfeart1/2, ppbhanxnafft1/2, ppbhanxncogt1/2, ppl2anxt1/2, ppl2anxshyt1/2, ppl2anxocbt1/2, ppl2anxfeart1/2, ppl2anxnafft1/2, ppl2anxncogt1/2

ARBQ Anxiety scales and subscales.
Prefix ppbh is for the parent behaviour/leap booklet.
Prefix ppl2 is for the parent leap2 booklet.
ppbhanxt1/2, ppl2anxt1/2: total scale derived from all 19 items.
ppbhanxshyt1/2, ppl2anxshyt1/2: shyness (social anxiety) subscale, from 3 items.
ppbhanxocbt1/2, ppl2anxocbt1/2: OCB (obsessive-compulsive behaviour) subscale, from 3 items.
ppbhanxfeart1/2, ppl2anxfeart1/2: fear subscale, from 3 items.
ppbhanxnafft1/2, ppl2anxnafft1/2: negative affect subscale, from 4 items.
ppbhanxncogt1/2, ppl2anxncogt1/2: negative cognition subscale, from 5 items.
The ARBQ scales at other ages include SDQ emotion items, but these were not present in the age 16 parent booklets. In other respects, these ARBQ scales are comparable with the TEDS ARBQ scales used at other ages and they use the same items.
Each item has integer values 0-2, hence each scale has values ranging from 0 to double the number of items. For each scale, at least half the items are required to be non-missing.
Published papers are broadly in agreement about the items used to make the subscales. At all ages where the items are present, the following decisions have been made about the use of the items:
(a) anx09, "twitches" is not used in any of the subscales, in agreement with at least two papers. This item was used in OCB by one paper and in negative affect by another paper.
(b) anx05, "asks for reassurance", is used in the negative cognition subscale, as in at least two papers. It was used in OCB by another paper.
(c) anx06, "doing things over and over", is used in the OCB subscale, in agreement with at least two papers. It was used in negative affect in another paper.

* ARBQ.
* Included in Parent Behaviour/Leap and in Leap-2.
* Shyness (social anxiety) subscale (3 items).
COMPUTE ppbhanxshyt1 = 3 * MEAN.2(ppbhanx021, ppbhanx031, ppbhanx071).
COMPUTE ppl2anxshyt1 = 3 * MEAN.2(ppl2anx021, ppl2anx031, ppl2anx071).
EXECUTE.

* OCB subscale (3 items).
COMPUTE ppbhanxocbt1 = 3 * MEAN.2(ppbhanx041, ppbhanx061, ppbhanx141).
COMPUTE ppl2anxocbt1 = 3 * MEAN.2(ppl2anx041, ppl2anx061, ppl2anx141).
EXECUTE.

* Fear subscale (3 items).
COMPUTE ppbhanxfeart1 = 3 * MEAN.2(ppbhanx011, ppbhanx081, ppbhanx181).
COMPUTE ppl2anxfeart1 = 3 * MEAN.2(ppl2anx011, ppl2anx081, ppl2anx181).
EXECUTE.

* Negative affect subscale (4 items).
COMPUTE ppbhanxnafft1 = 4 * MEAN.2(ppbhanx101, ppbhanx121, ppbhanx161, ppbhanx171).
COMPUTE ppl2anxnafft1 = 4 * MEAN.2(ppl2anx101, ppl2anx121, ppl2anx161, ppl2anx171).
EXECUTE.

* Negative cognition subscale (5 items).
COMPUTE ppbhanxncogt1 = 5 * MEAN.3(ppbhanx051, ppbhanx111, ppbhanx131, ppbhanx151, ppbhanx191).
COMPUTE ppl2anxncogt1 = 5 * MEAN.3(ppl2anx051, ppl2anx111, ppl2anx131, ppl2anx151, ppl2anx191).
EXECUTE.

* Total scale (all 19 items).
* hence including all items from the 5 subscales above.
* plus anx09 (twitches) which has a very small positive correlation.
* with all other items but does not clearly belong to any subscale.
COMPUTE ppbhanxt1 = 19 * MEAN.10(ppbhanx011, ppbhanx021, ppbhanx031,
 ppbhanx041, ppbhanx051, ppbhanx061, ppbhanx071, ppbhanx081, ppbhanx091,
 ppbhanx101, ppbhanx111, ppbhanx121, ppbhanx131, ppbhanx141, ppbhanx151,
 ppbhanx161, ppbhanx171, ppbhanx181, ppbhanx191).
COMPUTE ppl2anxt1 = 19 * MEAN.10(ppl2anx011, ppl2anx021, ppl2anx031,
 ppl2anx041, ppl2anx051, ppl2anx061, ppl2anx071, ppl2anx081, ppl2anx091,
 ppl2anx101, ppl2anx111, ppl2anx121, ppl2anx131, ppl2anx141, ppl2anx151,
 ppl2anx161, ppl2anx171, ppl2anx181, ppl2anx191).
EXECUTE.
ppbhaqatst1/2, ppbhaqdett1/2, ppbhaqimat1/2, ppbhaqsoct1/2, ppbhaqt1/2

See pcbhaqdett1/2, etc above.

ppbhconnemlt1/2, ppbhconnimpt1/2, ppbhconninat1/2, ppbhconnt1/2

Conners ADHD and Emotional Lability scales.
Derived from items of the Conners measure in the parent behaviour study booklet.
The Emotional Lability part of the measure just has a total scale (3 items).
The ADHD part of the measure has a total scale (18 items) plus two subscales (9 items each).
Each item has integer values 0-3, hence each scale has a range of values from 0 to (3 * number of component items) as it a 'total' computed by multiplying the mean by the number of items.

* Emotional Lability scale (3 items).
COMPUTE ppbhconnemlt1 = 3 * MEAN.2(ppbhconn191, ppbhconn201, ppbhconn211).
EXECUTE .

* Impulsivity scale (9 items).
COMPUTE ppbhconnimpt1 = 9 * MEAN.5(ppbhconn011, ppbhconn051, ppbhconn081,
 ppbhconn101, ppbhconn111, ppbhconn131, ppbhconn141, ppbhconn161, ppbhconn181) .
EXECUTE .

* Inattention scale (9 items).
COMPUTE ppbhconninat1 = 9 * MEAN.5(ppbhconn021, ppbhconn031, ppbhconn041,
 ppbhconn061, ppbhconn071, ppbhconn091, ppbhconn121, ppbhconn151, ppbhconn171) .
EXECUTE .

* total scale (all 18 ADHD-related items).
COMPUTE ppbhconnt1 = 18 * MEAN.9(ppbhconn011, ppbhconn021, ppbhconn031,
 ppbhconn041, ppbhconn051, ppbhconn061, ppbhconn071, ppbhconn081, ppbhconn091,
 ppbhconn101, ppbhconn111, ppbhconn121, ppbhconn131, ppbhconn141, ppbhconn151,
 ppbhconn161, ppbhconn171, ppbhconn181).
EXECUTE .
ppbhicutcalt1/2, ppbhicutunct1/2, ppbhicutunet1/2, ppbhicutt1/2

See pcbhicutcalt1/2, etc above.

ppbhlfevnat1/2, ppbhlfevnnt1/2, ppbhlfevpat1/2, ppbhlfevpnt1/2

See pcbhlfevnat1/2, etc above.

ppbhLLCage, ppbhLLCdate

See pcbhLLCage1/2, etc above.

ppbhmfqt1/2

See pcbhmfqt1/2, ppbhmfqt1/2 above.

ppbhsansafft1/2, ppbhsansalot1/2, ppbhsansanat1/2, ppbhsansattt1/2, ppbhsansavat1/2, ppbhsanst1/2, ppl2sansafft1/2, ppl2sansalot1/2, ppl2sansanat1/2, ppl2sansattt1/2, ppl2sansavat1/2, ppl2sanst1/2

SANS scales.
Total scale (all 10 items) and five subscales (2 items each).
Derived from items of the SANS measure in the parent behaviour/leap and leap-2 booklets.
Variable names starting ppbh are from the behaviour/leap booklet, while variable names starting ppl2 are from the leap-2 booklet.
Each item has integer values 0-3, hence each scale has a range of values from 0 to (3 * number of items) because it is computed as the mean multiplied by the number of component items.

* Five subscales with 2 items each.

* Affective Flattening scale.
COMPUTE ppbhsansafft1 = 2 * MEAN.2(ppbhsans011, ppbhsans021).
COMPUTE ppl2sansafft1 = 2 * MEAN.2(ppl2sans011, ppl2sans021).
EXECUTE.

* Alogia scale.
COMPUTE ppbhsansalot1 = 2 * MEAN.2(ppbhsans031, ppbhsans041).
COMPUTE ppl2sansalot1 = 2 * MEAN.2(ppl2sans031, ppl2sans041).
EXECUTE.

* Avolition-Apathy scale.
COMPUTE ppbhsansavat1 = 2 * MEAN.2(ppbhsans051, ppbhsans061).
COMPUTE ppl2sansavat1 = 2 * MEAN.2(ppl2sans051, ppl2sans061).
EXECUTE.

* Anhedonia-Associality scale.
COMPUTE ppbhsansanat1 = 2 * MEAN.2(ppbhsans071, ppbhsans081).
COMPUTE ppl2sansanat1 = 2 * MEAN.2(ppl2sans071, ppl2sans081).
EXECUTE.

* Attention scale.
COMPUTE ppbhsansattt1 = 2 * MEAN.2(ppbhsans091, ppbhsans101).
COMPUTE ppl2sansattt1 = 2 * MEAN.2(ppl2sans091, ppl2sans101).
EXECUTE.

* Create total from all 10 items.
COMPUTE ppbhsanst1 = 10 * MEAN.5(ppbhsans011, ppbhsans021, ppbhsans031,
 ppbhsans041, ppbhsans051, ppbhsans061, ppbhsans071, ppbhsans081, ppbhsans091, ppbhsans101).
COMPUTE ppl2sanst1 = 10 * MEAN.5(ppl2sans011, ppl2sans021, ppl2sans031,
 ppl2sans041, ppl2sans051, ppl2sans061, ppl2sans071, ppl2sans081, ppl2sans091, ppl2sans101).
EXECUTE.
ppbhsdqbeht1/2, ppbhsdqcont1/2, ppbhsdqhypt1/2, ppbhsdqprot1/2

See pcbhsdqbeht1/2, etc above.

ppl2age

See pcbhage1/2, etc above.

ppl2anxt1/2, ppl2anxshyt1/2, ppl2anxocbt1/2, ppl2anxfeart1/2, ppl2anxnafft1/2, ppl2anxncogt1/2

See ppbhanxt1/2, etc above.

ppl2lfevnat1/2, ppl2lfevnnt1/2, ppl2lfevpat1/2, ppl2lfevpnt1/2

See pcbhlfevnat1/2, etc above.

ppl2LLCage, ppl2LLCdate

See pcbhLLCage1/2, etc above.

ppl2mfqt1/2

See pcbhmfqt1/2, etc above.

ppl2sansafft1/2, ppl2sansalot1/2, ppl2sansanat1/2, ppl2sansattt1/2, ppl2sansavat1/2, ppl2sanst1/2

See ppbhsansafft1/2, etc above.

ppl2sdqbeht1/2, ppl2sdqcont1/2, ppl2sdqhypt1/2, ppl2sdqprot1/2

See pcbhsdqbeht1/2, etc above.

ppwebdata

Flag variable to show the presence or absence of parent web data (SES questionnaire).
Derived from the item flag variable showing the presence of parent web consent.

* Add flag variables for parent web data.
COMPUTE ppwebdata = 0.
EXECUTE.
IF (ppconsent = 1) ppwebdata = 1.
EXECUTE.
pses

SES composite variable.
Derived from 5 items in the parent web SES questionnaire, as a standardised mean.

* First filter out all the standard exclusions for the twin pair.
* (medical, perinatal, unknown sex/zyg, missing 1st Contact).
* 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.

* Parent-rated SES.
* standardise the five component variables.
DESCRIPTIVES VARIABLES=pphhinc ppmohqual ppmosoc ppfahqual ppfasoc
  /SAVE .
* make reversed versions for SOC.
COMPUTE Zppmosocr = -1 * Zppmosoc.
COMPUTE Zppfasocr = -1 * Zppfasoc.
EXECUTE.
* find the mean, requiring at least 3 components to be non-missing.
COMPUTE ses = MEAN.3(Zpphhinc, Zppmohqual, Zppfahqual, Zppmosocr, Zppfasocr).
EXECUTE.
* standardise it.
DESCRIPTIVES VARIABLES= ses (pses)
  /SAVE .
* Just keep pses - drop other temporary variables at the end of this script.

* All the variables have now been computed on the filtered sample.
* They will have missing values for the exclusions.
* The filter can now be removed.
FILTER OFF.
USE ALL.
EXECUTE .