// Program: kr1999_mtusx.do // Task: 1999 Korean MTUS-X main and survey files // Project: MTUS-X file // Created: 06/15/2020 // Program setup ******************************************************************************** set more off set linesize 80 set varabbrev off clear all // Variables ******************************************************************************** clear all set linesize 80 set more off use kr1999_time.dta, clear sort col1 col27 //background variables *country: country or region of study gen country="KR" *survey: year the survey began gen survey=1999 *swave: longitudinal study wave marker *** gen swave=-9 *msamp: multiple samples using the same diary instrument gen msamp=-9 *hldid: household identifier gen hldid=col1 *persid: person/diarist identifier gen persid=col27 sort hldid persid *cday: calendar date gen cday = -9 *day: day of week diary kept gen day=-5 replace day=1 if (col48==5 & diary==1) | ((col340==12 | col340==5) & diary==2) //Sunday replace day=2 if (col48==6 & diary==1) | (col340==6 & diary==2) //Monday replace day=3 if (col48==7 & diary==1) | (col340==7 & diary==2) //Tuesday replace day=4 if (col48==8 & diary==1) | (col340==8 & diary==2) //Wednesday replace day=5 if (col48==9 & diary==1) | (col340==9 & diary==2) //Thursday replace day=6 if ((col48==10|col48==3) & diary==1) | (col340==10 & diary==2) //Friday replace day=7 if ((col48==11|col48==4) & diary==1) | ((col340==4|col340==11) & diary==2) //Saturday *month: Month diary kept gen month=9 //only one month of September *year: year diary kept gen year=1999 *parntid1: parent id gen parntid1 = -9 *parntid2: parent id gen parntid2 = -9 *partid gen partid = -9 *hhtype: household type gen hhtype=-9 *hhldsize: number of people in household egen hld_tag=tag (hldid persid) egen hhldsize = sum(hld_tag), by(hldid) *nchild: number of children under 18 in household gen nchild=-9 *agekidx: age of youngest child in household categorical gen agekidx=-9 *agekid2: age of youngest child, non-categorical gen agekid2 = -9 *empinclm: Original monthly employment income gen empinclm=-9 *income: total household income gen income=-9 *ownhome: rental/own gen ownhome = -5 replace ownhome = 1 if col6==1 replace ownhome = 2 if col6==2 | col6==3 replace ownhome = 3 if col6==4 *urban: urban or rural household gen urban=-5 replace urban=1 if col4==2 replace urban=2 if col4==1 *computer gen computer=-9 *vehicle gen vehicle=col8 *sex:sex gen sex=col29 *age: age gen age=col30 recode age (90/max=90) //capped at 90 * famstat: family status gen famstat = -9 * singpar: single parent gen singpar = -9 *relrefp gen relrefp=-5 replace relrefp = 1 if col28==1 replace relrefp = 2 if col28==2 replace relrefp = 3 if col28==3 //unmarried child only replace relrefp = 4 if col28==6 //own parents and in-laws are included. replace relrefp = 5 if col28==8 replace relrefp = 6 if col28==4 //can't differenciate between married child and their spouse replace relrefp = 9 if col28==9 | col28==5 *civstat:couple gen civstat=2 replace civstat=1 if col33==2 *cohab gen cohab=-9 *citizen gen citizen = -9 *wherborn gen wherborn = -9 *emp: in paid work recode col38 (2=0) (1=1), gen(emp) *empstat: employment status & workhrs gen workhrs=-5 replace workhrs=col41 replace workhrs=-7 if emp==0 gen empstat=-5 replace empstat=1 if workhrs>=30 replace empstat=2 if workhrs>0 & workhrs<30 replace empstat=3 if (empstat==-5 & workhrs==0) replace empstat=4 if emp==0 tab empstat,missing *unemp gen unemp = -9 *student gen student = -5 replace student = 1 if col32==2 replace student = 0 if student==-5 *retired gen retired=-9 *empsp gen empsp =-9 *edcat:harmonised highest level of education gen edcat=-5 replace edcat=1 if (col31>=0 & col31<=2) |(col31==3 & inlist(col32, 2, 3, 4)) replace edcat=2 if (col31==3 & col32==1) replace edcat=3 if (col31>=4 & col32<=6) *rushed recode col46 (4 3 = 0)(2=1)(1=2), gen(rushed) *health gen health=-9 *carer gen carer=-9 *disab gen disab=-9 *ocombwt gen ocombwt=col630 //time variables order hldid persid d1time* d1loc* d1act* s1time* s1act* keep hldid persid d1time* d1loc* d1act* s1time* s1act* sort hldid persid egen a = seq() reshape long d1time d1loc d1act s1time s1act , i(a) j(tsl) sort a tsl drop if d1time==. sort a tsl *tsset a tsl gen begin1=d1time gen finish1=0 replace finish1 = begin1[_n+1]-1 replace finish1 = 144 if finish1 ==0 *clockst, start, end* gen start1 = -5 replace start1=(begin1-1)*10 gen end1 = -5 replace end1=finish1*10 order a tsl start1 end1 begin1 finish1 gen cl_temp1=0 replace cl_temp1=start1 gen cl_hour1=trunc(cl_temp1/60) gen cl_min1=((cl_temp1-(cl_hour1*60))*0.01) gen clockst1 = -5 replace clockst1=cl_hour1+cl_min1 format clockst1 %12.2f gen duration1 = end1 - start1 bys a: egen totime1=total(duration1) tab totime1 count if totime1!=1440 replace end1=1440 if end1==. replace finish1=144 if finish1==. replace duration1=40 if duration1==. replace totime1=1440 if totime1!=1440 drop totime1 *epnum gen epnum=-3 bys a: egen max_epnum=max(tsl) *main 69 activities* gen main = -5 replace main = 2 if inlist(d1act, 111, 112, 143) replace main = 4 if inlist(d1act, 131, 132, 141, 199) replace main = 6 if inlist(d1act, 121, 122, 123) replace main = 7 if inlist(d1act, 211, 214, 260) replace main = 8 if d1act == 215 replace main = 9 if inlist(d1act, 212, 220, 230) replace main = 11 if d1act == 822 replace main = 12 if d1act == 213 replace main = 13 if d1act == 216 | d1act == 299 replace main = 14 if d1act == 250 replace main = 15 if inlist(d1act, 311, 312, 314, 319, 321) replace main = 16 if inlist(d1act, 313, 322) replace main = 17 if inlist(d1act, 329, 731, 732, 733, 734, 739, 330) replace main = 18 if inlist(d1act, 411, 413) replace main = 19 if d1act == 412 replace main = 20 if inlist(d1act, 431, 432, 433) replace main = 21 if inlist(d1act, 421, 422, 423) replace main = 22 if inlist(d1act, 441, 442) replace main = 23 if inlist(d1act, 461, 462, 499, 443) replace main = 24 if inlist(d1act, 451, 452, 453, 780) replace main = 25 if inlist(d1act, 133, 142) replace main = 26 if inlist(d1act, 424, 463) replace main = 28 if inlist(d1act, 511, 521) replace main = 29 if d1act == 522 replace main = 30 if d1act == 512 replace main = 31 if inlist(d1act, 523, 519, 529) replace main = 32 if inlist(d1act, 530, 540, 550) replace main = 33 if inlist(d1act, 610, 620, 630, 641, 642, 643, 644, 649, 919) replace main = 34 if inlist(d1act, 741, 742, 743) replace main = 36 if d1act == 754 replace main = 37 if inlist(d1act, 751, 752) replace main = 38 if inlist(d1act, 753,759) replace main = 39 if d1act == 775 replace main = 40 if inlist(d1act, 714, 719) replace main = 42 if inlist(d1act, 763, 764, 766) replace main = 43 if inlist(d1act, 761, 762) replace main = 45 if d1act == 765 replace main = 46 if d1act == 240 replace main = 48 if inlist(d1act, 712, 713) replace main = 49 if d1act == 711 replace main = 50 if d1act == 773 replace main = 51 if d1act == 799 replace main = 54 if inlist(d1act, 774, 425) replace main = 55 if inlist(d1act, 776, 777) replace main = 56 if inlist(d1act, 771, 721, 722) replace main = 57 if d1act == 726 replace main = 58 if d1act == 725 replace main = 59 if inlist(d1act, 723, 724) replace main = 60 if d1act == 772 replace main = 61 if d1act == 727 replace main = 63 if d1act == 821 replace main = 64 if d1act == 831 replace main = 65 if d1act == 861 replace main = 66 if d1act == 851 replace main = 67 if inlist(d1act, 811, 841) replace main = 68 if inlist(d1act, 800, 871, 872, 891) replace main = 69 if inlist(d1act, 999) drop if main==-5 //2847 -- bad diary *secondary 69 activities* gen sec= -5 replace sec= 2 if inlist(s1act, 111, 112, 143) replace sec= 4 if inlist(s1act, 131, 132, 141, 199) replace sec= 6 if inlist(s1act, 121, 122, 123) replace sec= 7 if inlist(s1act, 211, 214, 260) replace sec= 8 if s1act == 215 replace sec= 9 if inlist(s1act, 212, 220, 230) replace sec= 11 if s1act == 822 replace sec= 12 if s1act == 213 replace sec= 13 if s1act == 216 | s1act == 299 replace sec= 14 if s1act == 250 replace sec= 15 if inlist(s1act, 311, 312, 314, 319, 321) replace sec= 16 if inlist(s1act, 313, 322) replace sec= 17 if inlist(s1act, 329, 731, 732, 733, 734, 739, 330) replace sec= 18 if inlist(s1act, 411, 413) replace sec= 19 if s1act == 412 replace sec= 20 if inlist(s1act, 431, 432, 433) replace sec= 21 if inlist(s1act, 421, 422, 423) replace sec= 22 if inlist(s1act, 441, 442) replace sec= 23 if inlist(s1act, 461, 462, 499, 443) replace sec= 24 if inlist(s1act, 451, 452, 453, 780) replace sec= 25 if inlist(s1act, 133, 142) replace sec= 26 if inlist(s1act, 424, 463) replace sec= 28 if inlist(s1act, 511, 521) replace sec= 29 if s1act == 522 replace sec= 30 if s1act == 512 replace sec= 31 if inlist(s1act, 523, 519, 529) replace sec= 32 if inlist(s1act, 530, 540, 550) replace sec= 33 if inlist(s1act, 610, 620, 630, 641, 642, 643, 644, 649, 919) replace sec= 34 if inlist(s1act, 741, 742, 743) replace sec= 36 if s1act == 754 replace sec= 37 if inlist(s1act, 751, 752) replace sec= 38 if inlist(s1act, 753,759) replace sec= 39 if s1act == 775 replace sec= 40 if inlist(s1act, 714, 719) replace sec= 42 if inlist(s1act, 763, 764, 766) replace sec= 43 if inlist(s1act, 761, 762) replace sec= 45 if s1act == 765 replace sec= 46 if s1act == 240 replace sec= 48 if inlist(s1act, 712, 713) replace sec= 49 if s1act == 711 replace sec= 50 if s1act == 773 replace sec= 51 if s1act == 799 replace sec= 54 if inlist(s1act, 774, 425) replace sec= 55 if inlist(s1act, 776, 777) replace sec= 56 if inlist(s1act, 771, 721, 722) replace sec= 57 if s1act == 726 replace sec= 58 if s1act == 725 replace sec= 59 if inlist(s1act, 723, 724) replace sec= 60 if s1act == 772 replace sec= 61 if s1act == 727 replace sec= 63 if s1act == 821 replace sec= 64 if s1act == 831 replace sec= 65 if s1act == 861 replace sec= 66 if s1act == 851 replace sec= 67 if inlist(s1act, 811, 841) replace sec= 68 if inlist(s1act, 800, 871, 872, 891) replace sec= 69 if inlist(s1act, 999) replace sec = . if sec==-5 *core 25 categories* gen core25 = -5 replace core25 = 1 if main==2 | main==3 replace core25 = 2 if main==5 | main==6 replace core25 = 3 if main==1 | main==4 replace core25 = 4 if main==7 | main==8 | main==9 | main==10 | main==11 | /// main==12 | main==13 | main==14 replace core25 = 5 if main==15 | main==16 | main==17 replace core25 = 6 if main==18 | main==19 replace core25 = 7 if main==20 | main==21 | main==23 replace core25 = 8 if main==22 replace core25 = 9 if main==24 | main==25 | main==26 replace core25 = 10 if main==46 replace core25 = 11 if main==27 | main==47 replace core25 = 12 if main==32 replace core25 = 13 if main==28 | main==31 replace core25 = 14 if main==29 | main==30 replace core25 = 15 if main==34 replace core25 = 16 if main==33 replace core25 = 17 if main==63 | main==64 replace core25 = 18 if main==62 | main==65 | main==66 | main==67 | /// main==68 replace core25 = 19 if main==42 | main==43 | main==44 replace core25 = 20 if main==57 | main==58 | main==59 replace core25 = 21 if main==56 replace core25 = 22 if main==60 | main==61 replace core25 = 23 if main==35 | main==36 | main==37 | main==38 | /// main==39 | main==40 | main==41 | main==45 replace core25 = 24 if main==48 | main==49 | main==50 | main==51 | /// main==52 | main==53 | main==54 | main==55 replace core25 = 25 if main==69 *av41* gen av = -5 replace av = 1 if main==5 | main==7 | main==10 | main==12 | main==13 //location variable includes workplace and school together replace av = 2 if main==8 | main==14 replace av = 3 if main==9 replace av = 4 if main==15 | main==17 replace av = 5 if main==11 | main==63 | main==64 replace av = 6 if main==18 | main==19 replace av = 7 if main==20 | main==21 replace av = 8 if main==22 | main==23 | main==27 | main==32 replace av = 9 if main==46 replace av = 10 if main==24 | main==26 replace av = 11 if main==28 | main==29 | main==30 | main==31 replace av = 12 if main==66 | main==67 replace av = 13 if main==1 | main==4 replace av = 14 if main==25 replace av = 15 if main==6 replace av = 16 if main==2 | main==3 replace av = 17 if main==62 | main==65 | main==68 replace av = 18 if main==35 | main==38 | main==45 replace av = 19 if main==42 | main==44 replace av = 20 if main==36 replace av = 21 if main==43 | main==47 replace av = 22 if main==34 replace av = 23 if main==33 replace av = 24 if main==37 replace av = 25 if main==40 replace av = 27 if main==39 replace av = 29 if main==48 replace av = 30 if main==58 replace av = 31 if main==59 replace av = 32 if main==57 replace av = 33 if main==16 replace av = 34 if main==56 replace av = 36 if main==55 replace av = 37 if main==49 replace av = 38 if main==50 replace av = 39 if main==51 | main==52 | main==53 replace av = 40 if main==54 | main==60 | main==61 replace av = 41 if main==41 | main==69 *eloc* gen eloc = -5 replace eloc = 1 if d1loc == 1 replace eloc = 8 if d1loc! = 0 & d1loc! = 1 replace eloc = 9 if d1loc == 0 *inout* gen inout=-5 replace inout=1 if d1loc == 1 replace inout=2 if d1loc == 0 replace inout=3 if d1loc>1 *mtrav* gen mtrav=-5 replace mtrav=-7 if mtrav==-5 & (eloc==1 | inout==1) replace mtrav=1 if inlist(d1loc, 5, 6) replace mtrav=2 if inlist(d1loc, 3, 4, 7, 8) replace mtrav=3 if d1loc == 2 replace mtrav=4 if d1loc == 9 replace mtrav=-7 if mtrav==-5 //weight variables *propwt *time variables - main* gen miss = av41 //missing activities gen eatdrk = av6 + av15 + av27 + av28+ av29+ av38 lab var eatdrk "Time spent on eating and drinking (basic act.)" gen trav = av5 + av12 + av17 + av19 + av21+ av9+ av24 +av18 +av29 +av19 lab var trav "Time spent on traveling or exercise(basic act.)" gen rst = av16 + av36 lab var rst "Time spent on resting/sleeping (basic act.)" gen pcare = av13 + av14 lab var pcare "Time spent on personal care (basic act.)" gen misbasic = 0 replace misbasic = misbasic + 1 if eatdrk == 0 replace misbasic = misbasic + 1 if trav== 0 replace misbasic = misbasic + 1 if rst == 0 replace misbasic = misbasic + 1 if pcare == 0 lab var misbasic "number of missing basic activities (b.a.)" #delimit; lab def misbasic 0 "No missing b.a." 1 "One missing b.a." 2 "Two missing b.a." 3 "Three missing b.a." 4 "Four missing b.a." ; lab val misbasic misbasic ; #delimit cr *no gender or sex gen loss_sex_age=1 if sex<0 | age<0 replace loss_sex_age=0 if loss_sex_age==. * less than 7 episode count if max_epnum <7 *badcase* gen badcase = -5 replace badcase = 1 if miss>90 | max_epnum<7 | misbasic >1 | loss_sex_age==0 replace badcase = 0 if misbasic>1 & max_epnum>6 & miss<91 *propwt* egen count=count(badcase) egen countp_bis=count(badcase) if badcase==0 egen countp=min(countp_bis) gen day = diary sort sex age day egen daywt=group(sex age day) if badcase==0 egen ngroupsd=max(daywt) if badcase==0 by sex age day: egen daycount2=count(daywt) if badcase==0 sort sex age egen weekwt=group(sex age) if badcase==0 egen ngroupsp=max(weekwt) if badcase==0 by sex age: egen wkcount2=count(weekwt) if badcase==0 gen propwt=((wkcount2/7)/daycount2) if badcase==0 replace propwt=0 if badcase!=0 replace propwt=propwt*(count/countp) egen mean_weight=mean(propwt) replace propwt=propwt/mean_weight *nowght* gen nowght = -5 replace nowght = 1 if main69>90 replace nowght = 1 if max_epnum<7 replace nowght = 1 if (eatdrk==0 & rst==0 & pcare==0) tab nowght replace nowght=0 if nowght==-5 //missing variables gen id = diary gen incorig = -9 gen region = col2 gen occupo = col40 gen educa = col31 gen ethnicity = -9 gen ict = -9 gen alone = -9 gen child = -9 gen sppart = -9 gen animal = -9 gen oad = -9 gen isco1 = -5 replace isco1 = 0 if occupo == "A" replace isco1 = 1 if occupo == "0" replace isco1 = 2 if occupo == "1" replace isco1 = 3 if occupo == "2" replace isco1 = 4 if occupo == "3" replace isco1 = 5 if occupo == "4" replace isco1 = 6 if occupo == "5" replace isco1 = 7 if occupo == "6" replace isco1 = 8 if occupo == "7" replace isco1 = 9 if occupo == "8" replace isco1 = -7 if isco1 == -5 gen sector = -5 replace sector = 1 if col39 == "A" replace sector = 2 if col39 == "B" replace sector = 3 if col39 == "C" replace sector = 4 if col39 == "D" replace sector = 5 if col39 == "E" replace sector = 6 if col39 == "F" replace sector = 7 if col39 == "G" replace sector = 8 if col39 == "H" replace sector = 9 if col39 == "I" replace sector = 10 if col39 == "J" replace sector = 11 if col39 == "K" replace sector = 12 if col39 == "L" replace sector = 13 if col39 == "M" replace sector = 14 if col39 == "N" replace sector = 15 if col39 == "O" replace sector = 16 if col39 == "P" replace sector = 17 if col39 == "Q" replace sector = 18 if col39 == "R" replace sector = 19 if col39 == "S" replace sector = 20 if col39 == "T" replace sector = -7 if sector == -5 gen migrantd = -9 gen migrantm = -9 gen migrantf = -9