********************* Creation of MTUS variables *************************** clear all use C:\Users\Test\Documents\MTUS_X\Italia\2002\original\data\Ita2002initial.dta renvars, lower ***** 1. general information about the surveys and cases ***** *** 1.1 *** gen str3 country = "IT " drop survey gen str4 survey = "2002" gen swave = 0 gen msamp = 0 gen hldid = idhogar gen persid = npers gen id = 1 gen diary=1 * one diary per participant* ** merge *** egen persid2= concat ( hldid persid) * Because diaries are one-day diaries, hence persid = id *** 1.2 *** /* There are two kinds of information given on the day of the week at which the diary questionnaire was collected. The first is an aggregated variable - daygrouped: 1. Monday to Friday 2. Saturday 3. Sunday The second is a detailed date with day, month and year given. We use both of information to record dates in a way that Stata understands. */ rename daygrouped origday gen step1 = mdy(month, monthday, year) format step1 %d * the function "mdy" is used to return the corresponding elapsed date, * while the function "%d format" is for making the dates readable. gen day = dow(step1) gen daynew=7 if day==6 replace daynew=6 if day==5 replace daynew=5 if day==4 replace daynew=4 if day==3 replace daynew=3 if day==2 replace daynew=2 if day==1 replace daynew=1 if day==0 gen daygrouped = . if origday == 1 replace daygrouped = 1 if origday == 3 replace daygrouped = 7 if origday == 2 replace daygrouped = daynew if daygrouped == . drop step1 daynew day rename daygrouped day *** 1.3 *** /* We retain the original variable "month", but rename it in order to produce a duplicated variable for MTUS. */ rename month monthy gen month = monthy *cday* gen cday= monthday *month* *** 1.4 *** /* The diary collection period is from April 2002 to March 2003, hence the January to March diaries should have a year value of 2003 */ drop year gen year = 2002 if month >= 4 replace year = 2003 if month < 4 tab month year ***** 2. Demographic variables ***** /* The variable indicates the relationship of the diarist to the household reference person in Italian survey has 17 categories. This variable is uppermost important to be noted because of its frequent use for the creation of other variables. relation=1: the reference person. relation=2: spouse of the reference person. relation=3: live-in partner of the reference person of the household. relation=4: father/mother of the reference person of the household. relation=5: father/mother of the spouse of the reference person of the household. relation=6: son/daughter of the reference person of the household. relation=7: son/daughter of a previous marriage of the reference person of the household. relation=8: childīs spouse of the reference person of the household. relation=9: childīs live-in partner of the reference person of the household. relation=10: childīs son/daughter of the reference person of the household. relation=11: brother/sisterīs son/daughter of the reference person of the household. relation=12: brother/sister of the reference person of the household. relation=13: spouseīs brother/sister of the reference person of the household. relation=14: brother/sisterīs spouse of the reference person of the household. relation=15: brother/sisterīs live-in partner of the reference person of the household. relation=16: other relatives the reference person of the household. relation=17: not related person with the reference person of the household. */ * sex* /* age We top-code age at 80 */ rename age oage gen age = oage replace age = 80 if oage >= 80 tab age /* nchild */ sort hldid by hldid: gen chicos=1 if age<18 by hldid: egen nchild=count(chicos) by hldid: replace nchild=0 if nchild==. /* hhtype We create a variable to indicate the household size, and another variable to indicate the married couples. */ sort hldid by hldid : gen countno = ahhldsize gen couple = 1 if relation == 2 by hldid : egen hcouple = count(couple) gen hhtype = 1 if countno == 1 by hldid : replace hhtype = 2 if countno == 2 & hcouple == 1 by hldid : replace hhtype = 3 if countno > 2 & hcouple == 1 by hldid : replace hhtype = 4 if countno >=2 & hcouple ~= 1 /* relrefp */ gen relrefp=1 if relation==1 replace relrefp=2 if (relation==2 | relation==3) replace relrefp=3 if (relation==6 | relation==7) replace relrefp=4 if relation==4 replace relrefp=5 if relation==12 replace relrefp=6 if relation==8 | relation==9 replace relrefp=7 if relation==5 replace relrefp=8 if relation==13 | relation==14 | relation==15 replace relrefp=9 if relation==10 | relation==11 | relation==16 replace relrefp=10 if relation==17 /* agekid */ sort hldid * Identify those whose ages are below 18 by hldid: gen childage = age if age < 18 & hhtype ~= 1 sort hldid childage by hldid: replace childage = childage[1] * Identify those who are children of the reference person by hldid: replace childage = age if childage == . & relrefp == 3 sort hldid childage by hldid: replace childage = childage[1] * Identify those who have parents in the household: eg. a three-person household * in which the reference person lives with his/her parents, in this case, the reference * person is the youngest child of the household despite the fact that s/he could be * much older than the normal age of a child. sort hldid relrefp by hldid: gen parn = 1 if relrefp == 4 sort hldid parn by hldid: replace parn = parn[1] sort hldid relrefp by hldid: replace childage = age if childage == . & relrefp == 1 & parn == 1 by hldid: egen young = min(childage) replace young = -7 if young == . gen agekidx = 1 if (young>=0 & young<=4) replace agekidx = 2 if (young>=5 & young<=12) replace agekidx = 3 if (young>=13 & young<=17) replace agekidx = 4 if young >= 18 replace agekidx=-7 if young==-7 /* agekid2 */ gen agekid2 = young /* cohab The variable "cohab" indicates whether or not the diarist is cohabiting with a partner, despite if s/he is married or not. The variable "relation" indicates the relationship of the diarist with the reference person: if relation = 3 indicates the person is the partner of the reference person; if relation = 9 indicates the person is the partner of the child of the reference person; if relation = 15 indicates the person is the partner of the sibling of the reference person. */ sort hldid gen step1 = 1 if relation == 3 by hldid : egen con = sum(step1) gen step2 = 1 if relation == 4 & civicstat ~= 2 by hldid : egen parent = sum(step2) gen step3 = 1 if relation == 5 & civicstat ~= 2 by hldid : egen parepart = sum(step3) gen step4 = 1 if relation == 9 by hldid : egen rel9 = count(step4) gen step5 = 1 if relation == 15 by hldid : egen rel15 = count(step5) * We assign value 1 to variable "cohab" to indicate the diarist is cohabiting, * while the value 0 indicates that the diarist is married or in a civil partnership. gen cohab = . replace cohab = 0 if civicstat == 2 replace cohab = 1 if (relation == 1 & con == 1) | relation == 3 replace cohab = 1 if relation == 9 | relation == 15 replace cohab = 1 if relation == 4 & parent == 2 replace cohab = 1 if relation == 5 & parepart == 2 gen step4h = 1 if relation == 9 & sex == 1 by hldid : egen partfigh = sum(step4h) gen step4m=1 if (relation==9) & sex==2 by hldid : egen partfigm=sum(step4m) gen step5h= 1 if (relation==6 | relation==7) & sex==1 by hldid : egen figh=sum(step5h) gen step5m= 1 if (relation==6 | relation==7) & sex==2 by hldid : egen figm=sum(step5m) gen step6h= 1 if (relation==15) & sex==1 by hldid : egen partfrah=sum(step6h) gen step6m= 1 if (relation==15) & sex==2 by hldid : egen partfram=sum(step6m) gen step7h= 1 if (relation==12 | relation==13) & sex==1 by hldid : egen frah=sum(step7h) gen step7m= 1 if (relation==12 | relation==13) & sex==2 by hldid : egen fram=sum(step7m) gen step8h= 1 if (relation==16) & sex==1 by hldid : egen otherh=sum(step8h) gen step8m= 1 if (relation==16) & sex==2 by hldid : egen otherm=sum(step8m) gen step9h = 1 if (relation==17) & sex==1 by hldid : egen noreh=sum(step9h) gen step9m = 1 if (relation==17) & sex==2 by hldid : egen norem=sum(step9m) replace cohab = 1 if (otherh==2 | otherm==2 | noreh==2 | norem==2) & (step8h~=. | step8m~=. | step9m~=. | step9h~=.) replace cohab = 1 if figh==1 & partfigm==1 & (figh==1 | partfigm==1) & cohab==. replace cohab = 1 if figm==1 & partfigh==1 & (figm==1 | partfigh==1) & cohab==. replace cohab = 1 if frah==1 & partfram==1 & (frah==1 | partfram==1) & cohab==. replace cohab = 1 if fram==1 & partfrah==1 & (fram==1 | partfrah==1) & cohab==. replace cohab = 1 if (idhogar ==9763 & npers==5) replace cohab = 1 if (idhogar ==4865 & npers==4) replace cohab = 1 if (idhogar ==6253 & npers==4) replace cohab = 1 if (idhogar ==16464 & npers==3) replace cohab = 1 if (idhogar ==17950 & npers==2) replace cohab = -7 if cohab == . replace cohab = -7 if age < 15 tab cohab tab age cohab #delimit; drop step* con parent parepart con parent parepart parepart rel9 rel15 partfigh partfigm figh figm step6h partfrah partfram frah fram otherh otherm noreh norem partfigh partfigm figh figm partfrah partfram frah fram otherh otherm noreh noreh norem ; #delimit cr ***** /* hhldsize */ gen hhldsize = ahhldsize /* famstat */ gen famstat = 0 if nchild == 0 & age >= 18 & age <= 39 replace famstat = 3 if nchild == 0 & age >= 40 sort hldid by hldid : replace famstat = 1 if famstat == . & age >= 18 & agekidx == 1 by hldid : replace famstat = 2 if famstat == . & age >= 18 & (agekidx ==2 | agekidx == 3) replace famstat = 4 if age < 18 & (hhtype ~= 1 | hhtype ~= 2) replace famstat = 5 if age < 18 & (hhtype == 1 | hhtype == 2) tab famstat /* cphome */ gen cphome = 1 if civicstat ~= 2 & (relation == 6 | relation == 7) replace cphome = 0 if cphome == . tab famstat cphome * there are 263 cases coded as famstat == 4 (age < 17 and live with parents/guardians) and * also coded as cphome == 0 (not a child living in parental home) tab civicstat if famstat == 4 & cphome == 0 * they are not in couples tab relation if famstat == 4 & cphome == 0 * one of them is the reference person, 245 are the nephews of the reference person, * 11 of them are brothers/sisters of the reference person and 6 of them are relatives * of the reference person. sum age if famstat == 4 & cphome == 0 * their ages are between 3 to 17. replace cphome = 1 if famstat == 4 & cphome == 0 tab famstat cphome /* singpar */ gen step1 = 1 if relation == 6 sort hldid by hldid : egen step2 = sum(step1) * identify those reference person with children. gen singpar = 1 if step2 > 0 & civicstat == 1 & relation == 1 & cohab == . replace singpar = 0 if (step2==0 & relation==1) | (civicstat~=1 & relation==1) gen step3 = 1 if relation == 10 by hldid : egen step4 = sum(step3) * identify those who have children who live in the household might be single parents. gen step5 = 1 if relation == 11 by hldid : egen step6 = sum(step5) * identify those whose brother or sister who live in the household might be single parents. #delimit ; replace singpar = 1 if (step4 > 0 & civicstat == 1 )& (relation == 6 | relation == 7) & (singpar == . & cohab == .) |(step6 > 0 & civicstat == 1) & (relation == 12 | relation == 13) & (singpar == . & cohab == .) ; #delimit cr replace singpar=1 if civicstat==1 & (relation==4) & (singpar==. & cohab == .) replace singpar=1 if civicstat==1 & (relation==5) & (singpar==. & cohab == .) replace singpar=0 if singpar==. drop step* /* civstat */ gen civstat = 1 if civicstat == 2 replace civstat = 2 if civicstat ~= 2 * There are 386 diarists with relrefp = 2 but civstat ~= 2, we correct this * by reassign the value of 1 for those people. replace civstat = 1 if relrefp == 2 tab relrefp civstat /* disab The 7th category in the variable of occupstat allows diarist to indicate if s/he is disabled. We would use this information to construct the variable "disab". */ gen disab = 1 if occupstat == 7 replace disab = 0 if occupstat ~= 7 replace disab = -7 if occupstat == . tab disab /* urban The geographical information is given by the variable "domain", which has 6 categories. domain = 10 metropolitan area domain = 20 peripheral area of a metropolitan area domain = 30 municipality with up to 2,000 inhabitants domain = 40 municipality with 2,000 to 10,000 inhabitants domain = 50 municipality with 10,000 to 50,000 inhabitants domain = 60 municipality with more than 50,000 inhabitants */ gen urban = 1 if domain <= 20 | domain == 50 | domain == 60 replace urban = 2 if domain >= 30 & domain < 50 replace urban = -7 if urban == . /* ownhome The information on the tenure of the house is given by the variable "typetenure" in the original data. typetenure = 1: rent typetenure = 2: ownership typetenure = 3: usufruct (no legal ownership) typetenure = 4: title free typetenure = 5: other */ gen ownhome = 1 if typetenure == 2 replace ownhome = 2 if typetenure == 1 replace ownhome = 3 if (typetenure ~= 1 & typetenure ~=2) tab ownhome /* computer */ gen computer = 1 if pc == 6 | internet == 2 replace computer = 0 if pc ~= 6 & internet ~= 2 tab computer /* vehicle We use information on the ownership of bike, scoot, moto, car and boat to generate this variable. */ #delimit; gen vehicle = 4 if (ncar >= 2 | nmoto >= 2 | nscoot >= 2 | nboat >= 2) ; replace vehicle = 3 if (ncar == 1 & moto == 5 & boat == 1 & scoot == 3) | (nmoto == 1 & car == 7 & boat == 1 & scoot == 3) | (nboat == 1 & car == 7 & moto == 5 & scoot == 3) | (nscoot == 1 & car == 7 & boat == 1 & moto == 5) ; replace vehicle = 2 if (byke == 2 & moto == 5 & car == 7 & boat == 1) ; replace vehicle = 0 if byke == 1 & scoot == 3 & moto == 5 & car == 7 & boat == 1 ; #delimit cr replace vehicle = -9 if vehicle == . tab vehicle /* citizen No information in the original data given on diarist's citizenship */ gen citizen = -9 gen wherborn =-9 /* rushed This variable indicates if diarist generally feels rushed. In the original data, there is a question asking if the diarist feels stressed or not. We use it as analogue. */ gen rushed = 0 if stress == 4 replace rushed = 1 if stress == 3 replace rushed = 2 if stress == 1 | stress == 2 replace rushed = -7 if stress == . tab rushed /* health */ rename health salute gen health = 0 if salute == 4 replace health = 1 if salute == 3 replace health = 2 if salute == 2 replace health = 3 if salute == 1 replace health = -7 if salute == 5 tab health tab health age /* carer There is no straight question on whether diarist provides any level of routine care to an adult or a child with disability or health problem. However, there are two questions; the first one inquiries the diarist if his/her main reason for not working is because of care of a relative, the second question inquires if his/her main reason for not accepting a full-time work is because of old people. We use these two variables to construct the variable of "carer". */ gen carer = 1 if fullold == 4 | famnowork == 8 replace carer = 0 if carer == . tab carer ***** 3. Generate person identifiers: partid, parntid1, parntid2 ***** /* hldid: Household identifier civstat: Civic status 1 "Married or cohabiting" 2 "Not living with a spouse/partner" cohab: Respondent id cohabiting 0 "Not cohabiting" 1 "Cohabiting" relrefp: Relation to household reference person 1 "Person 1" 2 "Spouse/partner" 3-9 "related" 10 "not related" partid : Person identifier of spouse or partner -9 "only one person per household completed a diary" -7 "multiple people completed diaries in the household and the diarist does not have a spouse or partner" -8 "the diarist has a partner who should have but did not complete a diary or who cannot be identified" */ /* partid */ sort hldid /*Identify the spouse/partner of the reference person*/ by hldid: gen spid = persid if relrefp == 2 sort hldid spid by hldid: replace spid = spid[1] if spid == . by hldid: gen refid = persid if relrefp == 1 sort hldid refid by hldid: replace refid = refid[1] if refid == . by hldid: gen partid = refid if relrefp == 2 by hldid: replace partid = spid if relrefp == 1 /*Identify the spouse/partner of non-reference person*/ * child and son/daughter-in-law by hldid: gen chldid = persid if relrefp == 3 sort hldid chldid by hldid: replace chldid = chldid[1] if chldid == . by hldid: gen sdlawid = persid if relrefp == 6 sort hldid sdlawid by hldid: replace sdlawid= sdlawid[1] if sdlawid== . by hldid: replace partid = chldid if relrefp == 6 by hldid: replace partid = sdlawid if relrefp == 3 * siblings and brother/sister-in-law by hldid: gen sibid = persid if relrefp == 5 sort hldid sibid by hldid: replace sibid= sibid[1] if sibid== . by hldid: gen bslawid = persid if relrefp == 8 sort hldid bslawid by hldid: replace bslawid = bslawid[1] if bslawid == . by hldid: replace partid = sibid if relrefp == 8 by hldid: replace partid = bslawid if relrefp == 5 replace partid = -7 if partid == . lab var partid "Person identifier of spouse or partner" drop spid refid chldid sdlawid sibid bslawid /* parntid1 & parntid2 */ * We created two extra variables (parntid and parnt_no) * to identify the order number of the parents. sort hldid /*Identify the parents of the reference person*/ by hldid: gen parntid = persid if relrefp == 4 sort hldid relrefp persid by hldid relrefp: gen parnt_no = _n if relrefp == 4 by hldid: gen parntid1 = parntid if parnt_no == 1 by hldid: gen parntid2 = parntid if parnt_no == 2 sort hldid parntid1 by hldid: replace parntid1 = parntid1[1] if parntid1 == . sort hldid parntid2 by hldid: replace parntid2 = parntid2[1] if parntid2 == . replace parntid1 = . if relrefp ~= 1 replace parntid2 = . if relrefp ~= 1 /*Identify the parents of the "child"*/ by hldid: gen child = 1 if relrefp == 3 sort hldid child by hldid: replace child = child[1] if child == . by hldid: gen parent1 = persid if relrefp == 1 & child == 1 sort hldid parent1 by hldid: replace parent1 = parent1[1] if parent1 == . & child == 1 by hldid: gen parent2 = persid if relrefp == 2 & child == 1 sort hldid parent2 by hldid: replace parent2 = parent2[1] if parent2 == . & child == 1 replace parent1 = . if relrefp ~= 3 replace parent2 = . if relrefp ~= 3 replace parntid1 = parent1 if parntid1 == . & parent1 ~= . replace parntid2 = parent2 if parntid2 == . & parent2 ~= . replace parntid1 = -7 if parntid1 == . replace parntid2 = -7 if parntid2 == . lab var parntid1 "Person identifier of 1st parent of diarist" lab var parntid2 "Person identifier of 2nd parent of diarist" drop parntid child parent1 parent2 *** region*** *tab proreg* **proreg: region of orgin gen region=-7 **no observations** ***** 4. Employment, education and income ***** /* The aggregated level of the employment status in the original survey is shown below: occupstat== 1 occupied occupstat== 2 searching for job occupstat== 3 searching for first job occupstat== 4 military/volunteering service occupstat== 5 houseworker occupstat== 6 student occupstat== 7 disabled occupstat== 8 retired from working occupstat== 9 another condition */ /* workhrs In the original survey those who worked were given a "work questionnaire". They were asked about the number of hours they had worked during the week, which was coded into variable "numhrswork". They were also asked to fill information on the number of days worked during the week, which was coded into variable "numdaywork". */ gen workhrs=numhrswork if numhrswork>=0 & numdaywork<88 /*IF there is no information about the number of hours worked but the individuals were working, we assign the value "-8" (missing value). For the rest of the cases (people is not working) we assign the value "-7" (not applicable). */ replace workhrs=-8 if workhrs==0 & occupstat==1 replace workhrs=-7 if workhrs==0 & occupstat~=1 /* Finally, to remove the decimal number of the number of hours. */ rename workhrs workhrs_convert gen workhrs = round(workhrs_convert) replace workhrs=-9 if workhrs==. /* empstat & emp & unemp */ gen empstat = 1 if (occupstat== 1 | occupstat == 4) & fulltime==1 replace empstat = 2 if (occupstat == 1 | occupstat == 4) & fulltime==2 replace empstat = 3 if (occupstat == 1 | occupstat == 4) & (fulltime ~=2 & fulltime ~=1) replace empstat = 4 if (occupstat == 2 | occupstat == 3 | occupstat >= 5) gen emp = 1 if occupstat == 1 | occupstat== 4 replace emp = 0 if occupstat ~= 1 & occupstat ~= 4 gen unemp = 1 if (occupstat == 2 | occupstat == 3) replace unemp = 0 if (occupstat ~= 2 & occupstat ~= 3) replace emp = 1 if unemp == 1 & workhrs > 0 replace empstat = 3 if unemp == 1 & workhrs > 0 /* student & retired */ gen student = 1 if occupstat == 6 replace student = 0 if occupstat ~= 6 replace emp = 1 if student == 1 & workhrs > 0 replace empstat = 3 if student == 1 & workhrs > 0 gen retired = 1 if occupstat == 8 replace retired = 0 if occupstat ~= 8 replace emp = 1 if retired == 1 & workhrs > 0 replace empstat = 3 if retired == 1 & workhrs > 0 /* empsp The procedure of creating this variable is very similar to that of the creation the variable "partid" */ sort hldid /*Identify the spouse/partner of the reference person*/ by hldid: gen spid = empstat if relrefp == 2 sort hldid spid by hldid: replace spid = spid[1] if spid == . by hldid: gen refid = empstat if relrefp == 1 sort hldid refid by hldid: replace refid = refid[1] if refid == . by hldid: gen empsp = refid if relrefp == 2 by hldid: replace empsp = spid if relrefp == 1 /*Identify the spouse/partner of non-reference person*/ * child and son/daughter-in-law by hldid: gen chldid = empstat if relrefp == 3 sort hldid chldid by hldid: replace chldid = chldid[1] if chldid == . by hldid: gen sdlawid = empstat if relrefp == 6 sort hldid sdlawid by hldid: replace sdlawid= sdlawid[1] if sdlawid== . by hldid: replace empsp = chldid if relrefp == 6 by hldid: replace empsp = sdlawid if relrefp == 3 * siblings and brother/sister-in-law by hldid: gen sibid = empstat if relrefp == 5 sort hldid sibid by hldid: replace sibid= sibid[1] if sibid== . by hldid: gen bslawid = empstat if relrefp == 8 sort hldid bslawid by hldid: replace bslawid = bslawid[1] if bslawid == . by hldid: replace empsp = sibid if relrefp == 8 by hldid: replace empsp = bslawid if relrefp == 5 replace empsp = -7 if civstat == 2 * if the diarist is not married (when civstat = 2), empsp is automatically coded as -7. recode empsp -7 = -8 if civstat == 1 * if the diarist is married, but empsp is missing, we assign the value of -8 (no response) rather than -7 to the missings. tab empsp civstat replace empsp = -7 if partid == -7 tab relrefp empsp * check for distribution * drop spid refid chldid sdlawid sibid bslawid /* income, incorig and empinclm No information on the level of monthly net household income or individual income in the original data */ gen incorig = -9 gen income = -9 gen empinclm = -9 ***isco1*** ** we generate this variable a approximation of *posoccup*** gen isco1 = posoccup replace isco =0 if posoccup==10 replace isco =1 if posoccup==1 replace isco =2 if posoccup==6|posoccup==5|posoccup==2|posoccup==4|posoccup==7 replace isco =3 if posoccup==3 replace isco =4 if posoccup==9|posoccup==8 replace isco =5 if posoccup==11 replace isco =6 if posoccup==12 replace isco =8 if posoccup==13 replace isco =9 if posoccup==14 replace isco =-8 if posoccup==. /*occupstat*** 2 "finance/legal profsnl" 3 "science/engineering profsnl" 4 "civil and social services" 5 "education professional" 6 "medical professional" 7 "other professional" 8 "health/social care support" 9 "clerical or office support" 10 "security and armed forces" 11 "sales and services" 12 "farming or forestry" 13 "construction, assembly" 14 "self-employed non-professional" -7 "not applicable/not asked" -8 "missing" -9 "could not be created";*/ /* educa The variable "study" indicate the educational level achieved by the diarist. There are 9 categories and are in Italian. We keep the original labels of it. study == 1 dottorado di ricerca o specializzazione post-laurea (Research degree) study == 2 laurea (Second-level degree) study == 3 diploma universitario (First-level degree) study == 4 diploma scuola media superiore (4-5 anni) (High school diploma) study == 5 diploma scuola media superiore (2-3 anni) (High school diploma) study == 6 licenza scuola media inferiore (License school leaving) study == 7 licenza elementare (Primary) study == 8 nessun titolo (se leggere e scrivere) (No title, but can read and write) study == 9 nessun titolo (non sa leggere e/o scrivere) (No title, cannot read or write) */ gen educa = study replace educa = -7 if study == -7 replace educa = -8 if study == . rename educa edcat #delimit; lab def educa -7 "not applicable/not asked" 1 "Research degree" 2 "Second-level university degree" 3 "First-level university degree" 4 "High school diploma, 4-5 years" 5 "High school diploma, 2-3 years" 6 "School leaving license" 7 "Primary school" 8 "No title, but can read and write" 9 "No title, cannot read or write" /* edtry */ gen edtry = 3 if study <= 3 replace edtry = 2 if study >= 4 & study <= 6 replace edtry = 1 if study >= 7 replace edtry = -7 if study == . /* occup The occupation of the diarist is coded in variable "profcode" in the original data. */ gen occup = 2 if profcode == 11 replace occup = 1 if profcode == 12 replace occup = 7 if profcode == 13 replace occup = 7 if profcode == 14 replace occup = 5 if profcode == 21 replace occup = 3 if profcode == 22 replace occup = 3 if profcode == 23 replace occup = 6 if profcode == 24 replace occup = 5 if profcode == 25 replace occup = 3 if profcode == 26 replace occup = 7 if profcode == 31 replace occup = 8 if profcode == 32 replace occup = 9 if profcode == 33 replace occup = 8 if profcode == 34 replace occup = 9 if profcode == 41 replace occup = 8 if profcode == 42 replace occup = 7 if profcode == 51 replace occup = 7 if profcode == 52 replace occup = 7 if profcode == 53 replace occup = 8 if profcode == 54 replace occup = 11 if profcode == 55 replace occup = 13 if profcode == 61 replace occup = 13 if profcode == 62 replace occup = 13 if profcode == 63 replace occup = 12 if profcode == 64 replace occup = 13 if profcode == 65 replace occup = 13 if profcode == 66 replace occup = 13 if profcode == 71 replace occup = 13 if profcode == 72 replace occup = 13 if profcode == 73 replace occup = 13 if profcode == 74 replace occup = 14 if profcode == 81 replace occup = 14 if profcode == 82 replace occup = 14 if profcode == 83 replace occup = 14 if profcode == 84 replace occup = 14 if profcode == 85 replace occup = 14 if profcode == 86 replace occup = 10 if profcode == 90 replace occup = 10 if profcode == 98 replace occup = -7 if profcode < 11 | profcode == . replace occup = -8 if profcode == . tab occup tab occup edtry, row /* sector */ gen sector = -9 ***** 5. Time-use variables ***** /* We make some changes because the primary and secondary activites are coded as string variables. */ quietly for num 1/82: replace aprinX ="10011" if aprinX =="011" quietly for num 1/82: replace aprinX ="10012" if aprinX =="012" quietly for num 1/82: replace aprinX ="10001" if aprinX =="01" quietly for num 1/82: replace aprinX ="10002" if aprinX =="02" quietly for num 1/82: replace aprinX ="10003" if aprinX =="03" quietly for num 1/82: replace aprinX ="10021" if aprinX =="021" quietly for num 1/82: replace aprinX ="10031" if aprinX =="031" quietly for num 1/82: replace aprinX ="10032" if aprinX =="032" quietly for num 1/82: replace aprinX ="10039" if aprinX =="039" quietly for num 1/82: replace aprinX ="10211" if aprinX =="0211" quietly for num 1/82: replace aprinX ="10212" if aprinX =="0212" quietly for num 1/82: replace aprinX ="10391" if aprinX =="0391" quietly for num 1/82: replace aprinX ="101" if aprinX =="01" quietly for num 1/82: replace aprinX ="102" if aprinX =="02" quietly for num 1/82: replace aprinX ="103" if aprinX =="03" quietly for num 1/82: destring aprinX , generate(aprinXbis) quietly for num 1/82: drop aprinX quietly for num 1/82: rename aprinXbis aprinX quietly for num 1/82: replace secunX ="101" if secunX =="01" quietly for num 1/82: replace secunX ="102" if secunX =="02" quietly for num 1/82: replace secunX ="103" if secunX =="03" quietly for num 1/82: destring secunX , generate(secunXbis) quietly for num 1/82: drop secunX quietly for num 1/82: rename secunXbis secunX /* The variables must be created taking into account the starting and finishing hours and minutes. The reason is that the data are organised in episodes, and each episode can have different duration depending on the individuals. fhours = finishing hour fminutes = finishing minute shours = starting hour sminutes = starting minute For computing the time variables we use the following syntax , and the only change we have to make is to substitue aprinX ~=. */ quietly for num 1/82: gen durX =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if aprinX ~=. & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82: replace durX =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if aprinX ~=. & fhoursX =sminutesX quietly for num 1/82: replace durX =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if aprinX ~=. & fhoursX >=shoursX & fminutesX =100 & aprinX <1000) /* If the individual has reported any unknown activity, but in the transport column there is information about travels from/to work/house/shopping, we replace the unknown activity with these activities. */ quietly for num 1/82: replace aprinX =lugarX if ((aprinX >=9970 & aprinX <10000) & (lugarX >=50 & lugarX <=63)) /* If the individual has reported any unknown activity but the secondary activity is known, we assign the secondary activity as the primary activity. */ quietly for num 1/82: replace aprinX =secunX if ((aprinX >=9970 & aprinX <10000) & secunX ~=.) quietly for num 1/82: replace aprinX =aprinX *10 if (aprinX >=100 & aprinX <1000) & (aprinX ~=211 & aprinX ~=212 & aprinX ~=391) /* Finally, if the lenght of the interval of the unknown activity is equal or less than 20 minutes, and the individual has reported any known activity We have to know the length of the interval, as a result we construct the variable "length". */ quietly for num 1/82: gen lenghtX =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if aprinX ~=. & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82: replace lenghtX =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if aprinX ~=. & fhoursX =sminutesX quietly for num 1/82: replace lenghtX =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if aprinX ~=. & fhoursX >=shoursX & fminutesX =9970 & aprin2<10000) & lenght2<=20 & lagaprin3~=. replace aprin3=lagaprin4 if (aprin3>=9970 & aprin3<10000) & lenght3<=20 & lagaprin4~=. replace aprin4=lagaprin5 if (aprin4>=9970 & aprin4<10000) & lenght4<=20 & lagaprin5~=. replace aprin5=lagaprin6 if (aprin5>=9970 & aprin5<10000) & lenght5<=20 & lagaprin6~=. replace aprin6=lagaprin7 if (aprin6>=9970 & aprin6<10000) & lenght6<=20 & lagaprin7~=. replace aprin7=lagaprin8 if (aprin7>=9970 & aprin7<10000) & lenght7<=20 & lagaprin8~=. replace aprin8=lagaprin9 if (aprin8>=9970 & aprin8<10000) & lenght8<=20 & lagaprin9~=. replace aprin9=lagaprin10 if (aprin9>=9970 & aprin9<10000) & lenght9<=20 & lagaprin10~=. replace aprin10=lagaprin11 if (aprin10>=9970 & aprin10<10000) & lenght10<=20 & lagaprin11~=. replace aprin11=lagaprin12 if (aprin11>=9970 & aprin11<10000) & lenght11<=20 & lagaprin12~=. replace aprin12=lagaprin13 if (aprin12>=9970 & aprin12<10000) & lenght12<=20 & lagaprin13~=. replace aprin13=lagaprin14 if (aprin13>=9970 & aprin13<10000) & lenght13<=20 & lagaprin14~=. replace aprin14=lagaprin15 if (aprin14>=9970 & aprin14<10000) & lenght14<=20 & lagaprin15~=. replace aprin15=lagaprin16 if (aprin15>=9970 & aprin15<10000) & lenght15<=20 & lagaprin16~=. replace aprin16=lagaprin17 if (aprin16>=9970 & aprin16<10000) & lenght16<=20 & lagaprin17~=. replace aprin17=lagaprin18 if (aprin17>=9970 & aprin17<10000) & lenght17<=20 & lagaprin18~=. replace aprin18=lagaprin19 if (aprin18>=9970 & aprin18<10000) & lenght18<=20 & lagaprin19~=. replace aprin19=lagaprin20 if (aprin19>=9970 & aprin19<10000) & lenght19<=20 & lagaprin20~=. replace aprin20=lagaprin21 if (aprin20>=9970 & aprin20<10000) & lenght20<=20 & lagaprin21~=. replace aprin21=lagaprin22 if (aprin21>=9970 & aprin21<10000) & lenght21<=20 & lagaprin22~=. replace aprin22=lagaprin23 if (aprin22>=9970 & aprin22<10000) & lenght22<=20 & lagaprin23~=. replace aprin23=lagaprin24 if (aprin23>=9970 & aprin23<10000) & lenght23<=20 & lagaprin24~=. replace aprin24=lagaprin25 if (aprin24>=9970 & aprin24<10000) & lenght24<=20 & lagaprin25~=. replace aprin25=lagaprin26 if (aprin25>=9970 & aprin25<10000) & lenght25<=20 & lagaprin26~=. replace aprin26=lagaprin27 if (aprin26>=9970 & aprin26<10000) & lenght26<=20 & lagaprin27~=. replace aprin27=lagaprin28 if (aprin27>=9970 & aprin27<10000) & lenght27<=20 & lagaprin28~=. replace aprin28=lagaprin29 if (aprin28>=9970 & aprin28<10000) & lenght28<=20 & lagaprin29~=. replace aprin29=lagaprin30 if (aprin29>=9970 & aprin29<10000) & lenght29<=20 & lagaprin30~=. replace aprin30=lagaprin31 if (aprin30>=9970 & aprin30<10000) & lenght30<=20 & lagaprin31~=. replace aprin31=lagaprin32 if (aprin31>=9970 & aprin31<10000) & lenght31<=20 & lagaprin32~=. replace aprin32=lagaprin33 if (aprin32>=9970 & aprin32<10000) & lenght32<=20 & lagaprin33~=. replace aprin33=lagaprin34 if (aprin33>=9970 & aprin33<10000) & lenght33<=20 & lagaprin34~=. replace aprin34=lagaprin35 if (aprin34>=9970 & aprin34<10000) & lenght34<=20 & lagaprin35~=. replace aprin35=lagaprin36 if (aprin35>=9970 & aprin35<10000) & lenght35<=20 & lagaprin36~=. replace aprin36=lagaprin37 if (aprin36>=9970 & aprin36<10000) & lenght36<=20 & lagaprin37~=. replace aprin37=lagaprin38 if (aprin37>=9970 & aprin37<10000) & lenght37<=20 & lagaprin38~=. replace aprin38=lagaprin39 if (aprin38>=9970 & aprin38<10000) & lenght38<=20 & lagaprin39~=. replace aprin39=lagaprin40 if (aprin39>=9970 & aprin39<10000) & lenght39<=20 & lagaprin40~=. replace aprin40=lagaprin41 if (aprin40>=9970 & aprin40<10000) & lenght40<=20 & lagaprin41~=. replace aprin41=lagaprin42 if (aprin41>=9970 & aprin41<10000) & lenght41<=20 & lagaprin42~=. replace aprin42=lagaprin43 if (aprin42>=9970 & aprin42<10000) & lenght42<=20 & lagaprin43~=. replace aprin43=lagaprin44 if (aprin43>=9970 & aprin43<10000) & lenght43<=20 & lagaprin44~=. replace aprin44=lagaprin45 if (aprin44>=9970 & aprin44<10000) & lenght44<=20 & lagaprin45~=. replace aprin45=lagaprin46 if (aprin45>=9970 & aprin45<10000) & lenght45<=20 & lagaprin46~=. replace aprin46=lagaprin47 if (aprin46>=9970 & aprin46<10000) & lenght46<=20 & lagaprin47~=. replace aprin47=lagaprin48 if (aprin47>=9970 & aprin47<10000) & lenght47<=20 & lagaprin48~=. replace aprin48=lagaprin49 if (aprin48>=9970 & aprin48<10000) & lenght48<=20 & lagaprin49~=. replace aprin49=lagaprin50 if (aprin49>=9970 & aprin49<10000) & lenght49<=20 & lagaprin50~=. replace aprin50=lagaprin51 if (aprin50>=9970 & aprin50<10000) & lenght50<=20 & lagaprin51~=. replace aprin51=lagaprin52 if (aprin51>=9970 & aprin51<10000) & lenght51<=20 & lagaprin52~=. replace aprin52=lagaprin53 if (aprin52>=9970 & aprin52<10000) & lenght52<=20 & lagaprin53~=. replace aprin53=lagaprin54 if (aprin53>=9970 & aprin53<10000) & lenght53<=20 & lagaprin54~=. replace aprin54=lagaprin55 if (aprin54>=9970 & aprin54<10000) & lenght54<=20 & lagaprin55~=. replace aprin55=lagaprin56 if (aprin55>=9970 & aprin55<10000) & lenght55<=20 & lagaprin56~=. replace aprin56=lagaprin57 if (aprin56>=9970 & aprin56<10000) & lenght56<=20 & lagaprin57~=. replace aprin57=lagaprin58 if (aprin57>=9970 & aprin57<10000) & lenght57<=20 & lagaprin58~=. replace aprin58=lagaprin59 if (aprin58>=9970 & aprin58<10000) & lenght58<=20 & lagaprin59~=. replace aprin59=lagaprin60 if (aprin59>=9970 & aprin59<10000) & lenght59<=20 & lagaprin60~=. replace aprin60=lagaprin61 if (aprin60>=9970 & aprin60<10000) & lenght60<=20 & lagaprin61~=. replace aprin61=lagaprin62 if (aprin61>=9970 & aprin61<10000) & lenght61<=20 & lagaprin62~=. replace aprin62=lagaprin63 if (aprin62>=9970 & aprin62<10000) & lenght62<=20 & lagaprin63~=. replace aprin63=lagaprin64 if (aprin63>=9970 & aprin63<10000) & lenght63<=20 & lagaprin64~=. replace aprin64=lagaprin65 if (aprin64>=9970 & aprin64<10000) & lenght64<=20 & lagaprin65~=. replace aprin65=lagaprin66 if (aprin65>=9970 & aprin65<10000) & lenght65<=20 & lagaprin66~=. replace aprin66=lagaprin67 if (aprin66>=9970 & aprin66<10000) & lenght66<=20 & lagaprin67~=. replace aprin67=lagaprin68 if (aprin67>=9970 & aprin67<10000) & lenght67<=20 & lagaprin68~=. replace aprin68=lagaprin69 if (aprin68>=9970 & aprin68<10000) & lenght68<=20 & lagaprin69~=. replace aprin69=lagaprin70 if (aprin69>=9970 & aprin69<10000) & lenght69<=20 & lagaprin70~=. replace aprin70=lagaprin71 if (aprin70>=9970 & aprin70<10000) & lenght70<=20 & lagaprin71~=. replace aprin71=lagaprin72 if (aprin71>=9970 & aprin71<10000) & lenght71<=20 & lagaprin72~=. replace aprin72=lagaprin73 if (aprin72>=9970 & aprin72<10000) & lenght72<=20 & lagaprin73~=. replace aprin73=lagaprin74 if (aprin73>=9970 & aprin73<10000) & lenght73<=20 & lagaprin74~=. replace aprin74=lagaprin75 if (aprin74>=9970 & aprin74<10000) & lenght74<=20 & lagaprin75~=. replace aprin75=lagaprin76 if (aprin75>=9970 & aprin75<10000) & lenght75<=20 & lagaprin76~=. replace aprin76=lagaprin77 if (aprin76>=9970 & aprin76<10000) & lenght76<=20 & lagaprin77~=. replace aprin77=lagaprin78 if (aprin77>=9970 & aprin77<10000) & lenght77<=20 & lagaprin78~=. replace aprin78=lagaprin79 if (aprin78>=9970 & aprin78<10000) & lenght78<=20 & lagaprin79~=. replace aprin79=lagaprin80 if (aprin79>=9970 & aprin79<10000) & lenght79<=20 & lagaprin80~=. replace aprin80=lagaprin81 if (aprin80>=9970 & aprin80<10000) & lenght80<=20 & lagaprin81~=. replace aprin81=lagaprin82 if (aprin81>=9970 & aprin81<10000) & lenght81<=20 & lagaprin82~=. for num 1/82: drop lenghtX for num 2/82: drop lagaprinX quietly for num 1/82:gen av1X =. quietly for num 1/82:replace av1X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=1100 & aprinX <1200) | (aprinX >=1300 & aprinX <1390) | aprinX ==13 | (aprinX >=1390 & aprinX <2000 & lugarX >14) | aprinX ==1 | aprinX ==11) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av1X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=1100 & aprinX <1200) | (aprinX >=1300 & aprinX <1390) | aprinX ==13 | (aprinX >=1390 & aprinX <2000 & lugarX >14) | aprinX ==1 | aprinX ==11) & fhoursX =sminutesX quietly for num 1/82:replace av1X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=1100 & aprinX <1200) | (aprinX >=1300 & aprinX <1390) | aprinX ==13 | (aprinX >=1390 & aprinX <2000 & lugarX >14) | aprinX ==1 | aprinX ==11) & fhoursX >=shoursX & fminutesX =1100 & aprinX <1200) | (aprinX >=1300 & aprinX <1390) | aprinX ==13 | (aprinX >=1390 & aprinX <2000 & lugarX >14) | aprinX ==1 | aprinX ==11) & fhoursX =1390 & aprinX <2000 & lugarX <=14) | (aprinX >=3700 & aprinX <3800 & aprinX ~= 3710)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av2X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=1390 & aprinX <2000 & lugarX <=14) | (aprinX >=3700 & aprinX <3800 & aprinX ~= 3710)) & fhoursX =sminutesX quietly for num 1/82:replace av2X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=1390 & aprinX <2000 & lugarX <=14) | (aprinX >=3700 & aprinX <3800 & aprinX ~= 3710)) & fhoursX >=shoursX & fminutesX =1390 & aprinX <2000 & lugarX <=14) | (aprinX >=3700 & aprinX <3800 & aprinX ~= 3710)) & fhoursX =1200 & aprinX <1300) | (aprinX >=9012 & aprinX <9013) | aprinX ==12) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av3X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=1200 & aprinX <1300) | (aprinX >=9012 & aprinX <9013) | aprinX ==12) & fhoursX =sminutesX quietly for num 1/82:replace av3X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=1200 & aprinX <1300) | (aprinX >=9012 & aprinX <9013) | aprinX ==12) & fhoursX >=shoursX & fminutesX =1200 & aprinX <1300) | (aprinX >=9012 & aprinX <9013) | aprinX ==12) & fhoursX =2100 & aprinX <2120) | (aprinX >=2190 & aprinX <3000) | (aprinX ==2 & lugarX ==19) | aprinX ==21) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av4X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=2100 & aprinX <2120) | (aprinX >=2190 & aprinX <3000) |(aprinX ==2 & lugarX ==19) | aprinX ==21) & fhoursX =sminutesX quietly for num 1/82:replace av4X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=2100 & aprinX <2120) | (aprinX >=2190 & aprinX <3000) |(aprinX ==2 & lugarX ==19) | aprinX ==21) & fhoursX >=shoursX & fminutesX =2100 & aprinX <2120) | (aprinX >=2190 & aprinX <3000) |(aprinX ==2 & lugarX ==19) | aprinX ==21) & fhoursX =9013 & aprinX <9020)| (aprinX >=9020 & aprinX <9030) | (aprinX >=9010 & aprinX <9012)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av5X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9013 & aprinX <9020)| (aprinX >=9020 & aprinX <9030) | (aprinX >=9010 & aprinX <9012)) & fhoursX =sminutesX quietly for num 1/82:replace av5X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9013 & aprinX <9020)| (aprinX >=9020 & aprinX <9030) | (aprinX >=9010 & aprinX <9012)) & fhoursX >=shoursX & fminutesX =9013 & aprinX <9020)| (aprinX >=9020 & aprinX <9030) | (aprinX >=9010 & aprinX <9012)) & fhoursX =3100 & aprinX <3200) | aprinX ==31) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av6X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3100 & aprinX <3200) | aprinX ==31) & fhoursX =sminutesX quietly for num 1/82:replace av6X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3100 & aprinX <3200) | aprinX ==31) & fhoursX >=shoursX & fminutesX =3100 & aprinX <3200) | aprinX ==31) & fhoursX =3200 & aprinX <3300 & aprinX ~= 3230) | (aprinX >=3300 & aprinX <3330) | aprinX ==3 | aprinX ==33 | aprinX ==32 | aprinX == 37 | aprinX == 3710) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av7X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3200 & aprinX <3300 & aprinX ~= 3230) | (aprinX >=3300 & aprinX <3330) | aprinX ==3 | aprinX ==33 | aprinX ==32 | aprinX == 37 | aprinX == 3710) & fhoursX =sminutesX quietly for num 1/82:replace av7X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3200 & aprinX <3300 & aprinX ~= 3230) | (aprinX >=3300 & aprinX <3330) | aprinX ==3 | aprinX ==33 | aprinX ==32 | aprinX == 37 | aprinX == 3710) & fhoursX >=shoursX & fminutesX =3200 & aprinX <3300 & aprinX ~= 3230) | (aprinX >=3300 & aprinX <3330) | aprinX ==3 | aprinX ==33 | aprinX ==32 | aprinX == 37 | aprinX == 3710) & fhoursX =3500 & aprinX <3600) | (aprinX >=3900 & aprinX <4000) | (aprinX >=4200 & aprinX <4300) | (aprinX ==4 & lugarX <=14) | aprinX ==35 | aprinX ==39 | aprinX ==42 | aprinX == 3230 |aprinX == 3390 |aprinX == 3420 | aprinX == 3430) & fhoursX >=shoursX & fminutesX >=sminutesX ; quietly for num 1/82: replace av8X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3500 & aprinX <3600) | (aprinX >=3900 & aprinX <4000) | (aprinX >=4200 & aprinX <4300) | (aprinX ==4 & lugarX <=14) | aprinX ==35 | aprinX ==39 | aprinX ==42 | aprinX == 3230 |aprinX == 3390 |aprinX == 3420 | aprinX == 3430) & fhoursX =sminutesX ; quietly for num 1/82: replace av8X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3500 & aprinX <3600) | (aprinX >=3900 & aprinX <4000) | (aprinX >=4200 & aprinX <4300) | (aprinX ==4 & lugarX <=14) | aprinX ==35 | aprinX ==39 | aprinX ==42 | aprinX == 3230 |aprinX == 3390 |aprinX == 3420 | aprinX == 3430) & fhoursX >=shoursX & fminutesX =3500 & aprinX <3600) | (aprinX >=3900 & aprinX <4000) | (aprinX >=4200 & aprinX <4300) | (aprinX ==4 & lugarX <=14) | aprinX ==35 | aprinX ==39 | aprinX ==42 | aprinX == 3230 |aprinX == 3390 |aprinX == 3420 | aprinX == 3430) & fhoursX =3400 & aprinX <3500 & aprinX ~= 3420 & aprinX ~= 3430 & aprinX ~= 3440) | aprinX ==34 | (aprinX > 6220 & aprinX < 6290)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av9X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3400 & aprinX <3500 & aprinX ~= 3420 & aprinX ~= 3430 & aprinX ~= 3440) | aprinX ==34 | (aprinX > 6220 & aprinX < 6290)) & fhoursX =sminutesX quietly for num 1/82:replace av9X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3400 & aprinX <3500 & aprinX ~= 3420 & aprinX ~= 3430 & aprinX ~= 3440) | aprinX ==34 | (aprinX > 6220 & aprinX < 6290)) & fhoursX >=shoursX & fminutesX =3400 & aprinX <3500 & aprinX ~= 3420 & aprinX ~= 3430 & aprinX ~= 3440) | aprinX ==34 | (aprinX > 6220 & aprinX < 6290)) & fhoursX =3600 & aprinX <3630) | (aprinX >=3640 & aprinX <3700) | aprinX ==36) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av10X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3600 & aprinX <3630) | (aprinX >=3640 & aprinX <3700) | aprinX ==36) & fhoursX =sminutesX quietly for num 1/82:replace av10X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3600 & aprinX <3630) | (aprinX >=3640 & aprinX <3700) | aprinX ==36) & fhoursX >=shoursX & fminutesX =3600 & aprinX <3630) | (aprinX >=3640 & aprinX <3700) | aprinX ==36) & fhoursX =3800 & aprinX <3900) | aprinX ==38 | aprinX == 8130) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av11X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3800 & aprinX <3900) | aprinX ==38 | aprinX == 8130) & fhoursX =sminutesX quietly for num 1/82:replace av11X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=3800 & aprinX <3900) | aprinX ==38 | aprinX == 8130) & fhoursX >=shoursX & fminutesX =3800 & aprinX <3900) | aprinX ==38 | aprinX == 8130) & fhoursX =9030 & aprinX <9040) | (aprinX >=9090 & aprinX <9100)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av12X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9030 & aprinX <9040) | (aprinX >=9090 & aprinX <9100)) & fhoursX =sminutesX quietly for num 1/82:replace av12X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9030 & aprinX <9040) | (aprinX >=9090 & aprinX <9100)) & fhoursX >=shoursX & fminutesX =9030 & aprinX <9040) | (aprinX >=9090 & aprinX <9100)) & fhoursX =shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av13X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if (aprinX == 10003 | aprinX ==10031 | aprinX == 10039 | aprinX == 10391) & fhoursX =sminutesX quietly for num 1/82:replace av13X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if (aprinX == 10003 | aprinX ==10031 | aprinX == 10039 | aprinX == 10391) & fhoursX >=shoursX & fminutesX =9000 & aprinX <9010) |(aprinX >=3630 & aprinX <3640) | aprinX ==0) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av14X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9000 & aprinX <9010) |(aprinX >=3630 & aprinX <3640) | aprinX ==0) & fhoursX =sminutesX quietly for num 1/82:replace av14X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9000 & aprinX <9010) | (aprinX >=3630 & aprinX <3640) | aprinX ==0) & fhoursX >=shoursX & fminutesX =9000 & aprinX <9010) | (aprinX >=3630 & aprinX <3640) | aprinX ==0) & fhoursX =27 & lugarX <= 38) | lugarX >=39)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av15X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX ==10021 | aprinX ==10211 | aprinX ==10212) & (lugarX <=19 | (lugarX >=27 & lugarX <= 38) | lugarX >=39)) & fhoursX =sminutesX quietly for num 1/82:replace av15X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX ==10021 | aprinX ==10211 | aprinX ==10212) & (lugarX <=19 | (lugarX >=27 & lugarX <= 38) | lugarX >=39)) & fhoursX >=shoursX & fminutesX =27 & lugarX <= 38) | lugarX >=39)) & fhoursX =shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av16X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if (aprinX ==10011 | aprinX ==10012) & fhoursX =sminutesX quietly for num 1/82:replace av16X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if (aprinX ==10011 | aprinX ==10012) & fhoursX >=shoursX & fminutesX =9040 & aprinX <9060)| (aprinX >=9070 & aprinX <9090) | (aprinX ==90) | (aprinX ==9) | (aprinX >=9060 & aprinX <9070)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av17X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9040 & aprinX <9060)| (aprinX >=9070 & aprinX <9090) | (aprinX ==90) | (aprinX ==9) | (aprinX >=9060 & aprinX <9070)) & fhoursX =sminutesX quietly for num 1/82:replace av17X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9040 & aprinX <9060)| (aprinX >=9070 & aprinX <9090) | (aprinX ==90) | (aprinX ==9) | (aprinX >=9060 & aprinX <9070)) & fhoursX >=shoursX & fminutesX =9040 & aprinX <9060)| (aprinX >=9070 & aprinX <9090) | (aprinX ==90) | (aprinX ==9) | (aprinX >=9060 & aprinX <9070)) & fhoursX =5290 & aprinX <6000) | (aprinX ==52) | (aprinX >=5230 & aprinX <5250)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av18X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=5290 & aprinX <6000) | (aprinX ==52) | (aprinX >=5230 & aprinX <5250)) & fhoursX =sminutesX quietly for num 1/82:replace av18X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=5290 & aprinX <6000) | (aprinX ==52) | (aprinX >=5230 & aprinX <5250)) & fhoursX >=shoursX & fminutesX =5290 & aprinX <6000) | (aprinX ==52) | (aprinX >=5230 & aprinX <5250)) & fhoursX =6120 & aprinX <6220) | (aprinX >6290 & aprinX <7000) | (aprinX ==6 | aprinX ==61 | aprinX ==62 | aprinX ==63)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av19X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=6120 & aprinX <6220) | (aprinX >6290 & aprinX <7000) | (aprinX ==6 | aprinX ==61 | aprinX ==62 | aprinX ==63)) & fhoursX =sminutesX quietly for num 1/82:replace av19X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=6120 & aprinX <6220) | (aprinX >6290 & aprinX <7000) | (aprinX ==6 | aprinX ==61 | aprinX ==62 | aprinX ==63)) & fhoursX >=shoursX & fminutesX =6120 & aprinX <6220) | (aprinX >6290 & aprinX <7000) | (aprinX ==6 | aprinX ==61 | aprinX ==62 | aprinX ==63)) & fhoursX =5250 & aprinX <5290) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av20X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=5250 & aprinX <5290) & fhoursX =sminutesX quietly for num 1/82:replace av20X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=5250 & aprinX <5290) & fhoursX >=shoursX & fminutesX =5250 & aprinX <5290) & fhoursX =6100 & aprinX <6120) | aprinX == 3440 | aprinX == 6220 | aprinX == 6290) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av21X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=6100 & aprinX <6120) | aprinX == 3440 | aprinX == 6220 | aprinX == 6290) & fhoursX =sminutesX quietly for num 1/82:replace av21X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=6100 & aprinX <6120) | aprinX == 3440 | aprinX == 6220 | aprinX == 6290) & fhoursX >=shoursX & fminutesX =6100 & aprinX <6120) | aprinX == 3440 | aprinX == 6220 | aprinX == 6290) & fhoursX =4320 & aprinX <4390) | (aprinX ==4 & lugarX ==38) | (aprinX ==43 & lugarX ==38)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av22X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=4320 & aprinX <4390) | (aprinX ==4 & lugarX ==38) | (aprinX ==43 & lugarX ==38)) & fhoursX =sminutesX quietly for num 1/82:replace av22X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=4320 & aprinX <4390) | (aprinX ==4 & lugarX ==38) | (aprinX ==43 & lugarX ==38)) & fhoursX >=shoursX & fminutesX =4320 & aprinX <4390) | (aprinX ==4 & lugarX ==38) | (aprinX ==43 & lugarX ==38)) & fhoursX =4100 & aprinX <4200) | (aprinX >=4300 & aprinX <4320) | (aprinX >=4390 & aprinX <5000) | (aprinX ==4 & lugarX ~=38 & lugarX ~=11 & lugarX ~=12 & lugarX ~=13 & lugarX ~=14) | aprinX ==41) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av23X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=4100 & aprinX <4200) | (aprinX >=4300 & aprinX <4320) | (aprinX >=4390 & aprinX <5000)| (aprinX ==4 & lugarX ~=38 & lugarX ~=11 & lugarX ~=12 & lugarX ~=13 & lugarX ~=14) | aprinX ==41) & fhoursX =sminutesX quietly for num 1/82:replace av23X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=4100 & aprinX <4200) | (aprinX >=4300 & aprinX <4320) | (aprinX >=4390 & aprinX <5000)| (aprinX ==4 & lugarX ~=38 & lugarX ~=11 & lugarX ~=12 & lugarX ~=13 & lugarX ~=14) | aprinX ==41) & fhoursX >=shoursX & fminutesX =4100 & aprinX <4200) | (aprinX >=4300 & aprinX <4320) | (aprinX >=4390 & aprinX <5000)| (aprinX ==4 & lugarX ~=38 & lugarX ~=11 & lugarX ~=12 & lugarX ~=13 & lugarX ~=14) | aprinX ==41) & fhoursX =5200 & aprinX <5230) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av24X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=5200 & aprinX <5230) & fhoursX =sminutesX quietly for num 1/82:replace av24X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=5200 & aprinX <5230) & fhoursX >=shoursX & fminutesX =5200 & aprinX <5230) & fhoursX =5130 & aprinX <5140) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av25X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=5130 & aprinX <5140) & fhoursX =sminutesX quietly for num 1/82:replace av25X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=5130 & aprinX <5140) & fhoursX >=shoursX & fminutesX =5130 & aprinX <5140) & fhoursX =5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & ((lugarX >=20 & lugarX <23) | lugarX ==33))) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av27X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((((aprinX >=5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & ((lugarX >=20 & lugarX <23) | lugarX ==33))) & fhoursX =sminutesX quietly for num 1/82:replace av27X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((((aprinX >=5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & ((lugarX >=20 & lugarX <23) | lugarX ==33))) & fhoursX >=shoursX & fminutesX =5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & ((lugarX >=20 & lugarX <23) | lugarX ==33))) & fhoursX =20 & lugarX <27)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av28X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX ==10021 | aprinX ==10211 | aprinX ==10212) & (lugarX >=20 & lugarX <27)) & fhoursX =sminutesX quietly for num 1/82:replace av28X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX ==10021 | aprinX ==10211 | aprinX ==10212) & (lugarX >=20 & lugarX <27)) & fhoursX >=shoursX & fminutesX =20 & lugarX <27)) & fhoursX =5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & lugarX ==14) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av29X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if (((aprinX >=5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & lugarX ==14) & fhoursX =sminutesX quietly for num 1/82:replace av29X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if (((aprinX >=5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & lugarX ==14) & fhoursX >=shoursX & fminutesX =5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & lugarX ==14) & fhoursX =8300 & aprinX <8320) | aprinX ==83) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av30X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8300 & aprinX <8320) | aprinX ==83) & fhoursX =sminutesX quietly for num 1/82:replace av30X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8300 & aprinX <8320) | aprinX ==83) & fhoursX >=shoursX & fminutesX =8300 & aprinX <8320) | aprinX ==83) & fhoursX =8200 & aprinX <8300) | aprinX ==8 | aprinX ==82) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av31X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8200 & aprinX <8300) | aprinX ==8 | aprinX ==82) & fhoursX =sminutesX quietly for num 1/82:replace av31X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8200 & aprinX <8300) | aprinX ==8 | aprinX ==82) & fhoursX >=shoursX & fminutesX =8200 & aprinX <8300) | aprinX ==8 | aprinX ==82) & fhoursX =8320 & aprinX <8400)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av32X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8320 & aprinX <8400)) & fhoursX =sminutesX quietly for num 1/82:replace av32X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8320 & aprinX <8400)) & fhoursX >=shoursX & fminutesX =8320 & aprinX <8400)) & fhoursX =2120 & aprinX <2190) | (aprinX ==2 & lugarX ~=19) | aprinX ==22) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av33X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=2120 & aprinX <2190) | (aprinX ==2 & lugarX ~=19) | aprinX ==22) & fhoursX =sminutesX quietly for num 1/82:replace av33X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=2120 & aprinX <2190) | (aprinX ==2 & lugarX ~=19) | aprinX ==22) & fhoursX >=shoursX & fminutesX =2120 & aprinX <2190) | (aprinX ==2 & lugarX ~=19) | aprinX ==22) & fhoursX =8120 & aprinX <8130) | aprinX ==81) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av34X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8120 & aprinX <8130) | aprinX ==81) & fhoursX =sminutesX quietly for num 1/82:replace av34X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8120 & aprinX <8130) | aprinX ==81) & fhoursX >=shoursX & fminutesX =8120 & aprinX <8130) | aprinX ==81) & fhoursX =8100 & aprinX <8120) | (aprinX > 8130 & aprinX <8200)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av35X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8100 & aprinX <8120) | (aprinX > 8130 & aprinX <8200)) & fhoursX =sminutesX quietly for num 1/82:replace av35X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=8100 & aprinX <8120) | (aprinX > 8130 & aprinX <8200)) & fhoursX >=shoursX & fminutesX =8100 & aprinX <8120) | (aprinX > 8130 & aprinX <8200)) & fhoursX =shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av36X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if (aprinX ==10032) & fhoursX =sminutesX quietly for num 1/82:replace av36X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if (aprinX ==10032) & fhoursX >=shoursX & fminutesX =5140 & aprinX <5150) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av37X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=5140 & aprinX <5150) & fhoursX =sminutesX quietly for num 1/82:replace av37X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=5140 & aprinX <5150) & fhoursX >=shoursX & fminutesX =5140 & aprinX <5150) & fhoursX =5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & ((lugarX >=15 & lugarX <20) | (lugarX >=23 & lugarX <33) | lugarX >33 | lugarX <=13)) | (aprinX ==43 & lugarX ~=38)) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av38X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((((aprinX >=5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & ((lugarX >=15 & lugarX <20) | (lugarX >=23 & lugarX <33) | lugarX >33 | lugarX <=13)) | (aprinX ==43 & lugarX ~=38)) & fhoursX =sminutesX quietly for num 1/82:replace av38X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((((aprinX >=5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & ((lugarX >=15 & lugarX <20) | (lugarX >=23 & lugarX <33) | lugarX >33 | lugarX <=13)) | (aprinX ==43 & lugarX ~=38)) & fhoursX >=shoursX & fminutesX =5100 & aprinX <5130) | (aprinX >=5150 & aprinX <5200) | aprinX ==5 | aprinX ==51) & ((lugarX >=15 & lugarX <20) | (lugarX >=23 & lugarX <33) | lugarX >33 | lugarX <=13)) | (aprinX ==43 & lugarX ~=38)) & fhoursX =3330 & aprinX <3400 & aprinX ~= 3390) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av39X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=3330 & aprinX <3400 & aprinX ~= 3390) & fhoursX =sminutesX quietly for num 1/82:replace av39X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if (aprinX >=3330 & aprinX <3400 & aprinX ~= 3390) & fhoursX >=shoursX & fminutesX =3330 & aprinX <3400 & aprinX ~= 3390) & fhoursX =7000 & aprinX <8000) | (aprinX >=8400 & aprinX <9000) | (aprinX >=9950 & aprinX <9970) | aprinX ==7 | aprinX ==71 | aprinX ==72 | aprinX ==73 | aprinX ==84) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av40X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=7000 & aprinX <8000) | (aprinX >=8400 & aprinX <9000) | (aprinX >=9950 & aprinX <9970) | aprinX ==7 | aprinX ==71 | aprinX ==72 | aprinX ==73 | aprinX ==84) & fhoursX =sminutesX quietly for num 1/82:replace av40X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=7000 & aprinX <8000) | (aprinX >=8400 & aprinX <9000) | (aprinX >=9950 & aprinX <9970) | aprinX ==7 | aprinX ==71 | aprinX ==72 | aprinX ==73 | aprinX ==84) & fhoursX >=shoursX & fminutesX =7000 & aprinX <8000) | (aprinX >=8400 & aprinX <9000) | (aprinX >=9950 & aprinX <9970) | aprinX ==7 | aprinX ==71 | aprinX ==72 | aprinX ==73 | aprinX ==84) & fhoursX =9970 & aprinX <10000) | aprinX ==99) & fhoursX >=shoursX & fminutesX >=sminutesX quietly for num 1/82:replace av41X =(((24-shoursX +fhoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9970 & aprinX <10000) | aprinX ==99) & fhoursX =sminutesX quietly for num 1/82:replace av41X =(((fhoursX -shoursX )*60) +(fminutesX -sminutesX )) if ((aprinX >=9970 & aprinX <10000) | aprinX ==99) & fhoursX >=shoursX & fminutesX =9970 & aprinX <10000) | aprinX ==99) & fhoursX 90 | nep < 7 | misbasic > 1 tab baddiary * Check if those miss more than 2 basic activities perform pet, * child or adult care. list av8 av11 if misbasic >=2 & (av8 ~= 0 | av11 ~= 0) /* The result shows that there are 19 diaries have more than 2 basic activities missing but having engaged in care.*/ * recode miss nep and misbasic recode miss 0/90 = 0 recode miss 91/max = 1 recode nep 0/6 = 1 recode nep 7/max = 0 recode misbasic 0/1 = 0 recode misbasic 2/4 = 1 #delimit; lab def misbasic 0 "one or none missing b.a." 1 "missing" at least two b.a." ; lab val misbasic misbasic ; #delimit cr tab misbasic ********************************************************* * number of missing | * basic activities | * (b.a.) | Freq. Percent Cum. *-------------------+----------------------------------- * No missing b.a. | 51,069 99.69 99.69 * One missing b.a. | 137 0.31 100.00 *-------------------+----------------------------------- * Total | 51,206 100.00 ********************************************************* bysort nep: tab miss misbasic *** 6.14) create variable "badcase" *** gen badcase = 0 if baddiary == 0 & sex > -8 & age > -8 & day > -8 replace badcase = 1 if baddiary == 0 & (sex == -8 | age == -8) & day > -8 replace badcase = 2 if baddiary == 0 & sex > -8 & age > -8 & day == -8 replace badcase = 3 if sex > -8 & age > -8 & day > -8 & nep == 0 & miss == 1 & misbasic == 0 replace badcase = 4 if sex > -8 & age > -8 & day > -8 & nep == 1 & miss == 0 & misbasic == 0 replace badcase = 5 if sex > -8 & age > -8 & day > -8 & nep == 0 & miss == 0 & misbasic == 1 replace badcase = 6 if (sex == -8 | age == -8) & day == -8 & nep == 0 & miss == 0 & misbasic == 0 replace badcase = 7 if (sex == -8 | age == -8) & day > -8 & nep == 0 & miss == 1 & misbasic == 0 replace badcase = 8 if (sex == -8 | age == -8) & day > -8 & nep == 1 & miss == 0 & misbasic == 0 replace badcase = 9 if (sex == -8 | age == -8) & day > -8 & nep == 0 & miss == 0 & misbasic == 1 replace badcase = 10 if sex > -8 & age > -8 & day == -8 & nep == 0 & miss == 1 & misbasic == 0 replace badcase = 11 if sex > -8 & age > -8 & day == -8 & nep == 1 & miss == 0 & misbasic == 0 replace badcase = 12 if sex > -8 & age > -8 & day == -8 & nep == 0 & miss == 0 & misbasic == 1 replace badcase = 13 if sex > -8 & age > -8 & day > -8 & nep == 1 & miss == 1 & misbasic == 0 replace badcase = 14 if sex > -8 & age > -8 & day > -8 & nep == 0 & miss == 1 & misbasic == 1 replace badcase = 15 if sex > -8 & age > -8 & day > -8 & nep == 1 & miss == 0 & misbasic == 1 replace badcase = 16 if (sex == -8 | age == -8) & day == -8 & nep == 0 & miss == 1 & misbasic == 0 replace badcase = 17 if (sex == -8 | age == -8) & day == -8 & nep == 1 & miss == 0 & misbasic == 0 replace badcase = 18 if (sex == -8 | age == -8) & day == -8 & nep == 0 & miss == 0 & misbasic == 1 replace badcase = 19 if (sex == -8 | age == -8) & day > -8 & nep == 1 & miss == 1 & misbasic == 0 replace badcase = 20 if (sex == -8 | age == -8) & day > -8 & nep == 0 & miss == 1 & misbasic == 1 replace badcase = 21 if (sex == -8 | age == -8) & day > -8 & nep == 1 & miss == 0 & misbasic == 1 replace badcase = 22 if sex > -8 & age > -8 & day == -8 & nep == 1 & miss == 1 & misbasic == 0 replace badcase = 23 if sex > -8 & age > -8 & day == -8 & nep == 0 & miss == 1 & misbasic == 1 replace badcase = 24 if sex > -8 & age > -8 & day == -8 & nep == 1 & miss == 0 & misbasic == 1 replace badcase = 25 if sex > -8 & age > -8 & day > -8 & nep == 1 & miss == 1 & misbasic == 1 replace badcase = 26 if (sex == -8 | age == -8) & day == -8 & nep == 1 & miss == 1 & misbasic == 0 replace badcase = 27 if (sex == -8 | age == -8) & day == -8 & nep == 0 & miss == 1 & misbasic == 1 replace badcase = 28 if (sex == -8 | age == -8) & day == -8 & nep == 1 & miss == 0 & misbasic == 1 replace badcase = 29 if (sex == -8 | age == -8) & day > -8 & nep == 1 & miss == 1 & misbasic == 1 replace badcase = 30 if sex > -8 & age > -8 & day == -8 & nep == 1 & miss == 1 & misbasic == 1 recode badcase . = 31 lab var badcase "Marker of low-quality cases" tab badcase ********************************************************************** * Marker of low-quality cases | Freq. Percent Cum. *------------------------------+-------------------------------------- * good case | 50,968 99.50 99.50 * miss 91+ minutes only | 86 0.17 99.66 * <7 episodes only | 15 0.03 99.69 * miss 2+ basic acts only | 122 0.28 99.97 * <7 ep & miss 2+ basic acts | 15 0.03 100.00 *-------------------- ---------+-------------------------------------- * Total | 51,206 100.00 *********************************************************************** tab badcase sex tab badcase nep tab badcase misbasic ***** 7. Weights ***** /* Three weights are given in the original data fweight: Weight of the household and person. 8 integeres, 4 decimals dweight: Weight of the day. 8 integeres, 4 decimals wweight: Weight of the week. 8 integeres, 4 decimals */ gen ocombwt = fweight * We create a age-sex population variable gen agegr5y=1 if age>=0 & age<=4 replace agegr5y=2 if age>=5 & age<=9 replace agegr5y=3 if age>=10 & age<=14 replace agegr5y=4 if age>=15 & age<=19 replace agegr5y=5 if age>=20 & age<=24 replace agegr5y=6 if age>=25 & age<=29 replace agegr5y=7 if age>=30 & age<=34 replace agegr5y=8 if age>=35 & age<=39 replace agegr5y=9 if age>=40 & age<=44 replace agegr5y=10 if age>=45 & age<=49 replace agegr5y=11 if age>=50 & age<=54 replace agegr5y=12 if age>=55 & age<=59 replace agegr5y=13 if age>=60 & age<=64 replace agegr5y=14 if age>=65 & age<=69 replace agegr5y=15 if age>=70 & age<=74 replace agegr5y=16 if age>=75 & age<=79 replace agegr5y=17 if age>=80 sort sex agegr5y egen agesexgp = group(sex agegr5y) if badcase == 0 tab agesexgp table agesexgp [pw = fweight] /* Construct the age-sex weight using the equation below: agesexwt = expected frequency / actual frequency i.e. agesexwt = frequency (weight is on) / frequency (weight is off) */ tab agesexgp gen agesexwt = 534 / 537 if agesexgp == 1 replace agesexwt = 1300 / 1341 if agesexgp == 2 replace agesexwt = 1376 / 1452 if agesexgp == 3 replace agesexwt = 1465 / 1482 if agesexgp == 4 replace agesexwt = 1412 / 1432 if agesexgp == 5 replace agesexwt = 1874 / 1726 if agesexgp == 6 replace agesexwt = 2007 / 1839 if agesexgp == 7 replace agesexwt = 2195 / 2065 if agesexgp == 8 replace agesexwt = 2089 / 1963 if agesexgp == 9 replace agesexwt = 1742 / 1857 if agesexgp == 10 replace agesexwt = 1768 / 1830 if agesexgp == 11 replace agesexwt = 1632 / 1629 if agesexgp == 12 replace agesexwt = 1517 / 1523 if agesexgp == 13 replace agesexwt = 1388 / 1333 if agesexgp == 14 replace agesexwt = 1212 / 1121 if agesexgp == 15 replace agesexwt = 832 / 757 if agesexgp == 16 replace agesexwt = 712 / 646 if agesexgp == 17 replace agesexwt = 477 / 489 if agesexgp == 18 replace agesexwt = 1204 / 1241 if agesexgp == 19 replace agesexwt = 1323 / 1380 if agesexgp == 20 replace agesexwt = 1338 / 1406 if agesexgp == 21 replace agesexwt = 1507 / 1524 if agesexgp == 22 replace agesexwt = 1903 / 1828 if agesexgp == 23 replace agesexwt = 1987 / 1961 if agesexgp == 24 replace agesexwt = 2436 / 2377 if agesexgp == 25 replace agesexwt = 2005 / 2046 if agesexgp == 26 replace agesexwt = 1805 / 1868 if agesexgp == 27 replace agesexwt = 1807 / 1851 if agesexgp == 28 replace agesexwt = 1671 / 1689 if agesexgp == 29 replace agesexwt = 1694 / 1675 if agesexgp == 30 replace agesexwt = 1687 / 1479 if agesexgp == 31 replace agesexwt = 1520 / 1347 if agesexgp == 32 replace agesexwt = 1222 / 1052 if agesexgp == 33 replace agesexwt = 1373 / 1222 if agesexgp == 34 egen agesexwt_mean = mean(agesexwt) if badcase == 0 gen popwt2 = agesexwt / agesexwt_mean if badcase == 0 replace popwt2 = 0 if badcase ~= 0 **** 2. daywt2 **** sort sex agegr5y day egen agesexdaygp = group (sex agegr5y day) if badcase == 0 tab agesexdaygp sort sex agegr5y day by sex agegr5y day: egen agesexdaycount = count (agesexdaygp) egen weekwt = group(sex agegr5y) if badcase == 0 by sex agegr5y: egen wkcount = count(weekwt) if badcase == 0 gen daywt2 = (wkcount/7)/agesexdaycount if badcase == 0 replace daywt2 = 0 if badcase ~= 0 /* Computation of the proposed weight propwt: proposed weight (population and day combined weight reescaled if needed) For good diaries: propwt = daywt2*popwt2 */ gen propwt = daywt2*popwt2 if badcase == 0 replace propwt = 0 if badcase ~= 0 /* Final step: inflate propwt to produce the total number of diary cases in the survey: propwt = propwt * (number of diaries in survey/number of good diaries in survey) */ replace propwt = propwt * (51206/(51206 - 238)) sort persid2 *** merge with the time variables*** keep country survey swave msamp hldid persid persid2 id day cday month year diary parntid1 parntid2 partid hhtype hhldsize nchild agekidx agekid2 income ownhome urban computer vehicle sex age famstat singpar relrefp civstat cohab citizen wherborn empstat emp unemp student retired empsp workhrs isco1 sector edcat rushed health carer disab ocombwt propwt *** merge with the time variables*** merge 1:m persid2 using "C:\Users\Test\Dropbox\episode.dta" order country survey swave msamp hldid persid persid2 id day cday month year diary time clockst start end epnum main core25 sec av inout eloc ict mtrav alone child sppart oad animal parntid1 parntid2 partid hhtype hhldsize nchild agekidx agekid2 income ownhome urban computer vehicle sex age famstat singpar relrefp civstat cohab citizen wherborn empstat emp unemp student retired empsp workhrs isco1 sector edcat rushed health carer disab ocombwt propwt sort persid2 epnum save "C:\Users\Test\Dropbox\Italia\2002\mtusx\main.dta", replace