**************************************************************************** **************************************************************************** *************** episodic HU1999 ******************************************** ************* * MAIN FILE * ************* keep AZONOSITO periodus tol1-tol44 ig1-ig44 tartam1-tartam44 fotev1-fotev44 meltev1-meltev44 kinek1-kinek44 /// kivel1-kivel44 jelen1-jelen44 hely1-hely44 catenate uniqID = AZONOSITO periodus reshape long tol ig tartam fotev meltev kinek kivel jelen hely, i(uniqID) j(slot) * location * gen eloc = hely recode eloc (0=-8) (1/15=1)(16/21=9)(21/24=3) (25/26=4) (27/32=9) (64=7) /// (33/36=5) (37/39=9) (40=5) (41/42=9) (43/46=6) (47/63 65/66=9) (67/80=8) (81/84=9) /// (85=5) (86/87=9) (88/98=8) (99=-8) * main * gen main= fotev recode main (470=2) (480/489 530/532=4) recode main (490/495=5) if (eloc==3 | eloc==4) recode main (490/495=6) if (eloc!=3 & eloc!=4 & eloc!=6) recode main (500/506=6) recode main (10/19 29/49 56/99 101/259=7) if eloc!=1 recode main (10/99 101/259=8) if eloc==1 recode main (403=9) if eloc!=1 recode main (461/469=10) recode main (501/506=12) if eloc==3 recode main (404 409=14) recode main (20/28=15) recode main (50/55=16) recode main (650/664=17) recode main (260/269 280/289=18) recode main (270/279=19) recode main (290/299=20) recode main (331/339=21) recode main (301/309=22) recode main (311/329=23) recode main (351/369=24) recode main (371/389 900/909 =25) recode main (391/409 =26) recode main (731/739=27) recode main (411 429=28) recode main (441/449=29) recode main (431/439=30) recode main (450/459=31) recode main (341/349=32) recode main (611/619=34) recode main (771/779=35) recode main (760=37) recode main (780/789=38) recode main (490/495 500/506 =39) if eloc==6 recode main (570/609=40) recode main (800 830/849=42) recode main (791/793=43) recode main (833=44) recode main (851/859=45) recode main (810 820=46) recode main (733=47) recode main (550/552=48) recode main (541/543=49) recode main (581/590=50) recode main (510 911 912 913 919 871 872 881/889=51) recode main (740/746=52) recode main (561/563=53) recode main (720/729 750=54) recode main (520=55) recode main (630/640=56) recode main (710 711 712=57) recode main (700/706=58) recode main (680 681=59) recode main (584=60) recode main (670 671 690 747/749=61) recode main (891=63) recode main (892=64) recode main (932=65) recode main (895=66) recode main (894=67) recode main (893 896 931 897 898 899 860 861 863 869=68) recode main (990=69) recode main (412/419 420/429=28) recode main (621/629=33) recode main (682/689=59) recode main (862=69) recode main (873=69) recode main (920=7) recode main (999=69) * sec* gen sec= meltev recode sec (470=2) (480/489 530/532=4) recode sec (490/495=5) if (eloc==3 | eloc==4) recode sec (490/495=6) if (eloc!=3 & eloc!=4 & eloc!=6) recode sec (500/506=6) recode sec (10/19 29/49 56/99 101/259=7) if eloc!=1 recode sec (10/99 101/259=8) if eloc==1 recode sec (403=9) if eloc!=1 recode sec (461/469=10) recode sec (501/506=12) if eloc==3 recode sec (404 409=14) recode sec (20/28=15) recode sec (50/55=16) recode sec (650/664=17) recode sec (260/269 280/289=18) recode sec (270/279=19) recode sec (290/299=20) recode sec (331/339=21) recode sec (301/309=22) recode sec (311/329=23) recode sec (351/369=24) recode sec (371/389 900/909 =25) recode sec (391/409 =26) recode sec (731/739=27) recode sec (411 429=28) recode sec (441/449=29) recode sec (431/439=30) recode sec (450/459=31) recode sec (341/349=32) recode sec (611/619=34) recode sec (771/779=35) recode sec (760=37) recode sec (780/789=38) recode sec (490/495 500/506 =39) if eloc==6 recode sec (570/609=40) recode sec (800 830/849=42) recode sec (791/793=43) recode sec (833=44) recode sec (851/859=45) recode sec (810 820=46) recode sec (733=47) recode sec (550/552=48) recode sec (541/543=49) recode sec (581/590=50) recode sec (510 911 912 913 919 871 872 881/889=51) recode sec (740/746=52) recode sec (561/563=53) recode sec (720/729 750=54) recode sec (520=55) recode sec (630/640=56) recode sec (710 711 712=57) recode sec (700/706=58) recode sec (680 681=59) recode sec (584=60) recode sec (670 671 690 747/749=61) recode sec (891=63) recode sec (892=64) recode sec (932=65) recode sec (895=66) recode sec (894=67) recode sec (893 896 931 897 898 899 860 861 863 869=68) recode sec (990=69) recode sec (412/419 420/429=28) recode sec (621/629=33) recode sec (682/689=59) recode sec (862=69) recode sec (873=69) recode sec (920=7) recode sec (999=69) recode sec (0=-8) * empty tails * bys uniqID: egen max_epi= max(slot) gen mis_time = . replace mis_time = tartam if main==. bys uniqID: egen sum_mis_time = sum(mis_time!=.) * dropping empty tails * gen no_main = . replace no_main = slot if main==. gen yes_main = . replace yes_main = slot if main!=. bys uniqID: egen min_mis = min(no_main) bys uniqID: egen max_slot = max(yes_main) bys uniqID: drop if _n > max_slot & _n >=min_mis * epnum* bys uniqID: gen epnum = _n ********************** * EPISODIC FOR MTUSX * ********************** * country* gen country= "HU" * survey* gen survey= 1999 *swave* gen swave=0 * msamp* gen msamp=0 *id* gen id= periodus *core25* gen core25 = main replace core25 = 1 if main ==2 | main==3 replace core25 = 2 if main ==5 | main==6 replace core25 = 3 if main ==1 | main==4 recode core25(7 8 9 10 11 12 13 14 =4) (15 16 17 =5) /// (18 19=6) (20 21 23 = 7) (22=8) (24 25 26=9) (46=10) (27 47=11) (32=12) (28 31=13) (29 30=14) /// (34=15) (33=16) (63 64=17) (62 65 66 67 68=18) (42 43 44=19) (57 58 59=20) (56=21) /// (60 61=22) (35 36 37 38 39 40 41 45=23) (48 49 50 51 52 53 54 55=24) (69=25) * av * gen av=. replace av = 1 if main ==5 | main==7 | main==10 | main==12 | main==13 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 = 28 if main==39 replace av = 29 if main==48 replace av = 38 if main==50 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 = 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 * clockst* gen clockst1=. replace clockst1= (240+start)/60 gen clockst=int(clockst1) gen clockst2 = (240+start) - (60*clockst) drop clockst1 rename clockst clockst1 recode clockst1 (24=0)(25=1) (26=2) (27=3) tostring clockst1, gen(clockst1_x) tostring clockst2, gen(clockst2_x) replace clockst2_x = "0" + clockst2_x if clockst2_x=="0" replace clockst2_x = "0" + clockst2_x if clockst2_x=="1" replace clockst2_x = "0" + clockst2_x if clockst2_x=="2" replace clockst2_x = "0" + clockst2_x if clockst2_x=="3" replace clockst2_x = "0" + clockst2_x if clockst2_x=="4" replace clockst2_x = "0" + clockst2_x if clockst2_x=="5" replace clockst2_x = "0" + clockst2_x if clockst2_x=="6" replace clockst2_x = "0" + clockst2_x if clockst2_x=="7" replace clockst2_x = "0" + clockst2_x if clockst2_x=="8" replace clockst2_x = "0" + clockst2_x if clockst2_x=="9" gen clockst = clockst1_x + "." + clockst2_x encode clockst, generate(clockst_num) drop clockst rename clockst_num clockst * inout* gen inout= hely recode inout (1/6 9/11 16/57 64 81/87=1) (7/8 12/15 58/63 65/70=2) (71/80 88/98=3) (99=-8) * mtrav* gen mtrav =hely replace mtrav = -7 if inout==1 | inout==2 recode mtrav ( 71 73 72=1) (74/80 89 90=2) (69 91=3) (70=4) (98 99=5) recode mtrav (88=2) * ict * gen ict=. replace ict = 1 if fotev ==584 | fotev==670 | fotev==671 | fotev==690 | fotev==747 | fotev==748 | fotev==749 replace ict = 1 if meltev ==584 | meltev==670 | meltev==671 | meltev==690 | meltev==747 | meltev==748 | meltev==749 replace ict=0 if ict==. * alone * gen alone=. replace alone=1 if kivel==0 replace alone=0 if alone==. * child* gen child = kivel recode child (12 13=1) (20/29=1) replace child=0 if child!=1 *sppart* gen sppart = kivel recode sppart (10/19=1) replace sppart =0 if sppart!=1 *oad* gen oad= kivel recode oad (36/39 45/50 56/70 78/98=1) replace oad = 0 if oad >1 * nowght* gen nowght=0 ******************************** * background vars for episodic * ******************************** * from idomerleg2000.dta * gen persid = AZONOSITO gen hldid = hsor gen hhldsize = haztag gen month = vnho gen day= vnapnev gen cday = vnap recode day (7=1) (1=2) (2=3) (3=4) (4=5) (5=6) (6=7) gen diary = periodus gen year = 1999 if periodus==1 | periodus==2 replace year = 2000 if periodus==3 | periodus==4 gen parntid1= - 9 gen parntid2=-9 gen urban= jogall recode urban (1 2 3=1) (4=2) recode urban (.=-8) gen hhtype=. replace hhtype=1 if hhldsize==1 replace hhtype=2 if hazszerk==3 | hazszerk==4 replace hhtype=3 if hazszerk==5 | hazszerk==6 | hazszerk==7 | hazszerk==8 replace hhtype=4 if hhtype==. & hazszerk!=. replace hhtype=-8 if hazszerk==. gen nchild=gyszam18 recode nchild (.=-8) gen sex=neme gen age=kev gen famstat=. replace famstat= 0 if age >=18 & age <=39 & (hazszerk==1 | hazszerk==3 | hazszerk==8 | hazszerk==11) replace famstat= 1 if age >=18 & (hazszerk==1 | hazszerk==5 | hazszerk==6 | hazszerk==7 | /// hazszerk==9 | hazszerk==10) replace famstat =3 if age >=40 & (hazszerk==1 | hazszerk==3 | hazszerk==8 | hazszerk==11) replace famstat =4 if age <18 &(hazszerk==1 | hazszerk==5 | hazszerk==6 | hazszerk==7 | /// hazszerk==9 | hazszerk==10) replace famstat = 4 if hazszerk==1 | hazszerk==3 | hazszerk==4 replace famstat =5 if age <18 & famstat==. replace famstat = -8 if famstat==. /* 0 Adult aged 18 to 39 with no co-resident children <18 1 Adult 18+ living with 1+ co-resident children aged <5 2 Adult 18+ living with 1+ co-resident children 5-17, none <5 3 Adult aged 40+ with no co-resident children <18 4 Respondent aged <18 and living with parent(s)/guardian(s) 5 Respondent aged <18, living arrangement other or unknown */ gen relrefp = -9 gen partid=-9 gen singpar = . replace singpar = 1 if hazszerk==9 | hazszerk==10 | hazszerk==11 replace singpar = 0 if singpar==. gen civstat=. replace civstat=1 if csal==3 | cspot==2 replace civstat=2 if cspot==1 | cspot==3 | cspot==4 | cspot==5 gen cohab=. replace cohab =-7 if civstat==2 replace cohab=0 if cspot==2 replace cohab=1 if csal==3 gen citizen=-9 gen whereborn=-9 gen empstat=. replace empstat=1 if mforr==1 replace empstat=3 if mforr==2 | mforr==5 | mforr==7 replace empstat=4 if mforr!=. & empstat==. gen emp = 1 if mforr==1 | mforr==2 | mforr==5 | mforr==7 replace emp=0 if emp==. gen unemp=. replace unemp = 1 if mforr==12 replace unemp=0 if unemp==. gen student=. replace student=1 if mforr==18 | mforr==19 | mforr==22 | mforr==21 | mforr==22 replace student=0 if student==. gen retired=. replace retired=1 if mforr==3 | mforr==10 replace retired=0 if retired==. gen empsp=-9 gen workhrs=-9 gen isco1=fog recode isco1 (110/310=0) (1110/1429=1) (2112/2910=2)(3111/3910=3) (4111/4299=4) /// (5111/5399=5) (6111/6411=6) (7113/7469=7) (8111/8390=8) (9111/9220=9) recode isco1 (7490/7649=7) recode isco1 (.=-7) gen sector=tul recode sector (2/7=2) (8 9 =-8) (.=-8) gen edcat=isk recode edcat (1 2 =1) (3 4 5 =2) (6 7 8=3) recode edcat (.=-8) gen rushed=-9 gen carer=-9 gen disab=. replace disab=1 if mforr==11 replace disab=0 if disab==. gen ocombwt=szorzo gen badcase=0 egen count=count(badcase) egen countp_bis=count(badcase) if badcase==0 egen countp=min(countp_bis) 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 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 ********************* * from E-MOD-20.dta * ********************* gen income= CSJOVK_2 replace income = 1 if CSJOVK_2 <=50000 replace income = 2 if CSJOVK_2 >50000 & CSJOVK_2 <=90000 replace income = 3 if CSJOVK_2 >90000 replace income = -8 if CSJOVK_2 ==. /* label define EPJELLEG /// 1 "városi bérház" /// 2 "lakótelepi panel" /// 3 "többlakásos zöldövezeti" /// 4 "családi ház" /// 5 "parasztház" /// 6 "egyéb" label val EPJELLEG EPJELLEG */ gen computer=SZGREND recode computer (2 3 =0) (9 .=-8) gen ownhome=-9 gen vehicle = SZGKOLD recode vehicle (2 3 4 .=-8) gen carer=-9 gen health=-9 ************************************ gen nowght=0 * merging in background vars * merge m:1 AZONOSITO periodus using idomerleg2000_mtux.dta, keepusing(persid hldid hhldsize month /// day cday diary year parntid1 parntid2 urban hhtype sex age nchild famstat relrefp partid /// singpar civstat cohab empstat emp unemp student retired empsp edcat workhrs sector isco1 /// rushed carer disab ocombwt badcase propwt health) *deleting redundant vars* keep country survey swave msamp hldid persid id day cday month year diary nowght /// 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 whereborn empstat emp unemp student retired empsp /// workhrs isco1 sector edcat rushed health carer disab ocombwt propwt order country survey swave msamp hldid persid id day cday month year diary nowght /// 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 whereborn empstat emp unemp student retired empsp /// workhrs isco1 sector edcat rushed health carer disab ocombwt propwt