*Syntax to create the MTUS W6 files for the Nethelands 1980. Written by Dr. José Ignacio Gimenez Nadal, University of Zaragoza (Spain) and Center for Time Use Research (University of Oxford). December 2010 *Cleaning the workspace and extending the size of the memory clear set more off set mem 900m set maxvar 15000 *Creating a working directory where all the files will be stored. The output data is in the working directory and all the original files must be in this directory before starting with the xharmonization process. local path="F:\Nacho\Data\MTUS_harmonization\Netherlands_80" cd `path' ******************************************************************************************************************************************************************************** ******************************************************************************************************************************************************************************** ************************************************************* WE READ THE DATA AND SAVE IT ************************************************************************************* ******************************************************************************************************************************************************************************** ******************************************************************************************************************************************************************************** clear use Netherlands_a_80.dta sort resp save Netherlands_a_80.dta, replace clear use Netherlands_b_80.dta capture rename respkw resp sort resp save Netherlands_b_80.dta, replace clear use Netherlands_h_80.dta sort resp save Netherlands_h_80.dta, replace clear use Netherlands_a_80.dta merge resp using Netherlands_b_80.dta sort resp drop _merge merge resp using Netherlands_h_80.dta drop _merge save Netherlands_1980.dta, replace ******************************************************************************************************************************************************************************** ******************************************************************************************************************************************************************************** ******************************************************************************************************************************************************************************** ******************************************************************************************************************************************************************************** clear use Netherlands_1980.dta drop a* b0* b1* b2* db* xakt* gr* zo* ma* di* wo* do* vr* za* ********************************************************************* DEMOGRAPHIC CHARACTERISTICS *************************************************************************** *COUNTRY generate countrya=22 *SURVEY generate survey=jaar *SWAVE generate swave=0 *MSAMP generate msamp=0 *HLDID generate hldid=0 **PERSID generate persid=resp **PARNTID1 gen parntid1=-9 **PARNTID2 gen parntid2=-9 **PARTID gen partid=-9 **MONTH generate month=10 if week==1 | week==2 replace month=11 if week==3 **YEAR generate year=jaar **SEX generate sex=sexe **AGE generate age=leef replace age=80 if age>=80 *CIVSTAT generate civstat=1 if burgsta==2 replace civstat=2 if burgsta==1 | burgsta==3 | burgsta==4 *COHAB generate cohab=-9 **STUDENT generate student=1 if werkzam3==3 replace student=0 if student==. **UNEMP generate unemp=1 if werkzaam==3 replace unemp=0 if unemp==. **EDUCA generate educa=oplhh3 replace educa=-8 if educa==. **EDTRY generate edtry=1 if oplhh3==1 replace edtry=2 if oplhh3==2 replace edtry=3 if oplhh3==3 replace edtry=-8 if edtry==. **EMPSP generate empsp=4 if partwerk==2 replace empsp=3 if partwerk==3 replace empsp=-7 if civstat==2 replace empsp=-8 if empsp==. **HHLDSIZE generate hhldsize=p0106 *HHTYPE generate hhtype=1 if p0105==1 replace hhtype=2 if p0105==2 replace hhtype=3 if p0105>2 replace hhtype=4 if hhtype==1 & hhldsize>1 replace hhtype=4 if hhtype==2 & hhldsize>2 replace hhtype=4 if hhldsize==2 & p0105>2 **RETIRED generate retired=1 if p06a==2 replace retired=0 if retired==. **URBAN generate urban=1 if wp02>=4 replace urban=2 if wp02<4 **RELREFP generate relrefp=1 if p0104==1 replace relrefp=2 if p0104==2 replace relrefp=1 if p0104==3 replace relrefp=3 if p0104==4 | p0104==5 **NCHILD generate nchild=p0107 replace nchild=nchild+1 if age==17 **AGEKIDX generate agekidx=1 if p0109<=4 replace agekidx=2 if (p0109>=5 & p0109<=12) replace agekidx=3 if (p0109>=13 & p0109<=17) replace agekidx=4 if p0109>17 replace agekidx=-8 if p0109==. replace agekidx=-7 if agekidx==1 & hhtype==1 replace agekidx=-7 if agekidx==1 & hhtype==2 **AGEKID2 generate agekid2=p0109 replace agekid2=-7 if p0109==. replace agekid2=-7 if agekidx==-7 replace agekidx=3 if age==17 & nchild==1 & agekidx==-7 replace agekidx=4 if age==18 & nchild==1 & agekidx==-7 replace agekid2=17 if age==17 & nchild==1 & agekid2==-7 replace agekid2=18 if age==18 & nchild==1 & agekid2==-7 replace nchild=0 if agekidx==4 **FAMSTAT generate famstat=0 if (nchild==0) & (age>=18 & age<=39) replace famstat=3 if (nchild==0) & age>=40 replace famstat=4 if age<18 & relrefp==3 replace famstat=5 if age<18 & relrefp!=3 replace famstat=1 if (age>=18) & agekidx==1 replace famstat=2 if (age>=18) & (agekidx==2 | agekidx==3) **EMP generate emp=1 if werkzam3==1 replace emp=0 if werkzam3==2 | werkzam3==3 replace emp=-8 if emp==. **EMPSTAT generate empstat=1 if uwpwv>=40 & uwpwv!=. replace empstat=2 if uwpwv<40 replace empstat=3 if emp==1 & empstat==. replace empstat=4 if empstat==. **WORKHRS generate workhrs=uwpwv replace workhrs=-8 if workhrs==. & emp==1 replace workhrs=-7 if workhrs==. **SINGPAR generate singpar=1 if civstat==2 & nchild>0 & relrefp==1 replace singpar=0 if singpar==. **CPHOME generate cphome=1 if relrefp==3 & civstat==2 replace cphome=0 if cphome==. **INCORIG generate incorig=s19a replace incorig=-8 if incorig==. **INCOME generate income=1 if s19a<=6 replace income=2 if s19a>7 & s19a<=12 replace income=3 if s19a==13 | s19a==14 replace income=-8 if income==. ** VARIABLES THAT CANNOT BE CREATED generate empinclm=-9 generate citizen=-9 generate computer=-9 generate occup=-9 generate ownhome=-9 generate sector=-9 generate rushed=-9 generate health=-9 generate disab=-9 **ROBUSTNESS CHECKS TO SEE THAT VARIABLES ARE PREFECTLY CODED ************************************************************* **CASES WHERE RELREFP==2 & CIVSTAT==2 replace civstat=1 if civstat==2 & hhldsize==7 & relrefp==2 replace relrefp=1 if relrefp==2 & civstat==2 & age==50 replace relrefp=1 if civstat==2 & relrefp==2 & nchild==2 replace civstat=1 if civstat==2 & relrefp==2 & nchild<2 **16 CASES WHERE CIVSTAT=2 AND HHTYPE==2 replace civstat=1 if civstat==2 & hhtype==2 **4 CASES WHERE CIVSTAT==1 & HHTYPE==4 replace civstat=2 if civstat==1 & hhtype==4 & nchild>0 replace hhtype=3 if civstat==1 & hhtype==4 & hhldsize==3 **SEVERAL CASES WHERE AGE<16 AND CIVSTAT==1 replace civstat=2 if age<16 **NO UNEMPLOYED INDIVIDUALS WITH MORE THAN 63 YEARS replace unemp=0 if age>=63 replace unemp=0 if age<16 **cases where the diarist is coded as not in a couple (civstat=2) but empsp=3 (working) replace empsp=-7 if civstat==2 replace empsp=-8 if empsp==-7 & civstat==1 **hhtype and civstat replace civstat=2 if hhtype==1 & civstat==1 ****************************************************************************************************************************************************************************** ****************************************************************************************************************************************************************************** ********************************************************************************* TIME USE VARIABLES ************************************************************************* ****************************************************************************************************************************************************************************** ****************************************************************************************************************************************************************************** *************************************************************************** DATA PREPARATION ********************************************************************************* **IMPUTED SLEEP==4710 local k=1 while `k'<8{ local i=2 while `i'<10{ local j=`i'-1 replace xha`k'0`i'=4710 if xha`k'0`i'==9999 & (xha`k'0`j'==4050 | xha`k'0`j'==4060 | xha`k'0`j'==4070) local i=`i'+1 } replace xha`k'10=4710 if xha`k'10==9999 & (xha`k'09==4050 | xha`k'09==4060 | xha`k'09==4070) local i=11 while `i'<97{ local j=`i'-1 replace xha`k'`i'=4710 if xha`k'`i'==9999 & (xha`k'`j'==4050 | xha`k'`j'==4060 | xha`k'`j'==4070) local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'+1 replace xha`k'0`i'=4710 if xha`k'0`i'==9999 & (xha`k'0`j'==4050 | xha`k'0`j'==4060 | xha`k'0`j'==4070) local i=`i'+1 } replace xha`k'09=4710 if xha`k'09==9999 & (xha`k'10==4050 | xha`k'10==4060 | xha`k'10==4070) local i=11 while `i'<96{ local j=`i'+1 replace xha`k'`i'=4710 if xha`k'`i'==9999 & (xha`k'`j'==4050 | xha`k'`j'==4060 | xha`k'`j'==4070) local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'+1 replace xha`k'0`i'=4710 if xha`k'0`i'==9999 & xha`k'0`j'==4710 local i=`i'+1 } replace xha`k'09=4710 if xha`k'09==9999 & xha`k'10==4710 local i=11 while `i'<96{ local j=`i'+1 replace xha`k'`i'=4710 if xha`k'`i'==9999 & xha`k'`j'==4710 local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'-1 replace xha`k'0`i'=4710 if xha`k'0`i'==9999 & xha`k'0`j'==4710 local i=`i'+1 } replace xha`k'10=4710 if xha`k'10==9999 & xha`k'09==4710 local i=11 while `i'<97{ local j=`i'-1 replace xha`k'`i'=4710 if xha`k'`i'==9999 & xha`k'`j'==4710 local i=`i'+1 } local k=`k'+1 } **IMPUTED TIME AWAY FROM HOME (7820) local k=1 while `k'<8{ local i=2 while `i'<10{ replace xha`k'0`i'=7820 if xha`k'0`i'==9999 & (pl`k'0`i'==2 | pl`k'0`i'==3) local i=`i'+1 } local i=10 while `i'<97{ replace xha`k'`i'=7820 if xha`k'`i'==9999 & (pl`k'`i'==2 | pl`k'`i'==3) local i=`i'+1 } local k=`k'+1 } **IMPUTED PERSONAL AND HOUSEHOLD CARE==4001 local k=1 while `k'<8{ local i=2 while `i'<10{ local j=`i'-1 replace xha`k'0`i'=4001 if xha`k'0`i'==9999 & ((xha`k'0`j'>=31 | xha`k'0`j'<40) | (xha`k'0`j'>=91 | xha`k'0`j'<96) | (xha`k'0`j'>=131 | xha`k'0`j'<1000) | (xha`k'0`j'>=1091 | xha`k'0`j'<1099) | (xha`k'0`j'>=1191 | xha`k'0`j'<=1194) | (xha`k'0`j'>=2091 | xha`k'0`j'<2099) | (xha`k'0`j'>=3091 | xha`k'0`j'<3099) | (xha`k'0`j'>=4091 | xha`k'0`j'<4099) | (xha`k'0`j'>=5091 | xha`k'0`j'<5099) | (xha`k'0`j'>=6091 | xha`k'0`j'<6099) | (xha`k'0`j'>=7091 | xha`k'0`j'<7099) | (xha`k'0`j'>=8091 | xha`k'0`j'<8099) | xha`k'0`j'==8091 | xha`k'0`j'==2191 | xha`k'0`j'==2194 | xha`k'0`j'==3191 | xha`k'0`j'==3194 | xha`k'0`j'==4191 | xha`k'0`j'==4194 | xha`k'0`j'==5191 | xha`k'0`j'==5194 | xha`k'0`j'==6191 | xha`k'0`j'==6194 | xha`k'0`j'==7191 | xha`k'0`j'==7194 | xha`k'0`j'==8191 | xha`k'0`j'==8194) local i=`i'+1 } replace xha`k'10=4001 if xha`k'10==9999 & ((xha`k'09>=31 | xha`k'09<40) | (xha`k'09>=91 | xha`k'09<96) | (xha`k'09>=131 | xha`k'09<1000) | (xha`k'09>=1091 | xha`k'09<1099) | (xha`k'09>=1191 | xha`k'09<=1194) | (xha`k'09>=2091 | xha`k'09<2099) | (xha`k'09>=3091 | xha`k'09<3099) | (xha`k'09>=4091 | xha`k'09<4099) | (xha`k'09>=5091 | xha`k'09<5099) | (xha`k'09>=6091 | xha`k'09<6099) | (xha`k'09>=7091 | xha`k'09<7099) | (xha`k'09>=8091 | xha`k'09<8099) | xha`k'09==8091 | xha`k'09==2191 | xha`k'09==2194 | xha`k'09==3191 | xha`k'09==3194 | xha`k'09==4191 | xha`k'09==4194 | xha`k'09==5191 | xha`k'09==5194 | xha`k'09==6191 | xha`k'09==6194 | xha`k'09==7191 | xha`k'09==7194 | xha`k'09==8191 | xha`k'09==8194) local i=11 while `i'<97{ local j=`i'-1 replace xha`k'`i'=4001 if xha`k'`i'==9999 & ((xha`k'`j'>=31 | xha`k'`j'<40) | (xha`k'`j'>=91 | xha`k'`j'<96) | (xha`k'`j'>=131 | xha`k'`j'<1000) | (xha`k'`j'>=1091 | xha`k'`j'<1099) | (xha`k'`j'>=1191 | xha`k'`j'<=1194) | (xha`k'`j'>=2091 | xha`k'`j'<2099) | (xha`k'`j'>=3091 | xha`k'`j'<3099) | (xha`k'`j'>=4091 | xha`k'`j'<4099) | (xha`k'`j'>=5091 | xha`k'`j'<5099) | (xha`k'`j'>=6091 | xha`k'`j'<6099) | (xha`k'`j'>=7091 | xha`k'`j'<7099) | (xha`k'`j'>=8091 | xha`k'`j'<8099) | xha`k'`j'==8091 | xha`k'`j'==2191 | xha`k'`j'==2194 | xha`k'`j'==3191 | xha`k'`j'==3194 | xha`k'`j'==4191 | xha`k'`j'==4194 | xha`k'`j'==5191 | xha`k'`j'==5194 | xha`k'`j'==6191 | xha`k'`j'==6194 | xha`k'`j'==7191 | xha`k'`j'==7194 | xha`k'`j'==8191 | xha`k'`j'==8194) local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'+1 replace xha`k'0`i'=4001 if xha`k'0`i'==9999 & ((xha`k'0`j'>=31 | xha`k'0`j'<40) | (xha`k'0`j'>=91 | xha`k'0`j'<96) | (xha`k'0`j'>=131 | xha`k'0`j'<1000) | (xha`k'0`j'>=1091 | xha`k'0`j'<1099) | (xha`k'0`j'>=1191 | xha`k'0`j'<=1194) | (xha`k'0`j'>=2091 | xha`k'0`j'<2099) | (xha`k'0`j'>=3091 | xha`k'0`j'<3099) | (xha`k'0`j'>=4091 | xha`k'0`j'<4099) | (xha`k'0`j'>=5091 | xha`k'0`j'<5099) | (xha`k'0`j'>=6091 | xha`k'0`j'<6099) | (xha`k'0`j'>=7091 | xha`k'0`j'<7099) | (xha`k'0`j'>=8091 | xha`k'0`j'<8099) | xha`k'0`j'==8091 | xha`k'0`j'==2191 | xha`k'0`j'==2194 | xha`k'0`j'==3191 | xha`k'0`j'==3194 | xha`k'0`j'==4191 | xha`k'0`j'==4194 | xha`k'0`j'==5191 | xha`k'0`j'==5194 | xha`k'0`j'==6191 | xha`k'0`j'==6194 | xha`k'0`j'==7191 | xha`k'0`j'==7194 | xha`k'0`j'==8191 | xha`k'0`j'==8194) local i=`i'+1 } replace xha`k'10=4001 if xha`k'10==9999 & ((xha`k'11>=31 | xha`k'11<40) | (xha`k'11>=91 | xha`k'11<96) | (xha`k'11>=131 | xha`k'11<1000) | (xha`k'11>=1091 | xha`k'11<1099) | (xha`k'11>=1191 | xha`k'11<=1194) | (xha`k'11>=2091 | xha`k'11<2099) | (xha`k'11>=3091 | xha`k'11<3099) | (xha`k'11>=4091 | xha`k'11<4099) | (xha`k'11>=5091 | xha`k'11<5099) | (xha`k'11>=6091 | xha`k'11<6099) | (xha`k'11>=7091 | xha`k'11<7099) | (xha`k'11>=8091 | xha`k'11<8099) | xha`k'11==8091 | xha`k'11==2191 | xha`k'11==2194 | xha`k'11==3191 | xha`k'11==3194 | xha`k'11==4191 | xha`k'11==4194 | xha`k'11==5191 | xha`k'11==5194 | xha`k'11==6191 | xha`k'11==6194 | xha`k'11==7191 | xha`k'11==7194 | xha`k'11==8191 | xha`k'11==8194) local i=11 while `i'<96{ local j=`i'+1 replace xha`k'`i'=4001 if xha`k'`i'==9999 & ((xha`k'`j'>=31 | xha`k'`j'<40) | (xha`k'`j'>=91 | xha`k'`j'<96) | (xha`k'`j'>=131 | xha`k'`j'<1000) | (xha`k'`j'>=1091 | xha`k'`j'<1099) | (xha`k'`j'>=1191 | xha`k'`j'<=1194) | (xha`k'`j'>=2091 | xha`k'`j'<2099) | (xha`k'`j'>=3091 | xha`k'`j'<3099) | (xha`k'`j'>=4091 | xha`k'`j'<4099) | (xha`k'`j'>=5091 | xha`k'`j'<5099) | (xha`k'`j'>=6091 | xha`k'`j'<6099) | (xha`k'`j'>=7091 | xha`k'`j'<7099) | (xha`k'`j'>=8091 | xha`k'`j'<8099) | xha`k'`j'==8091 | xha`k'`j'==2191 | xha`k'`j'==2194 | xha`k'`j'==3191 | xha`k'`j'==3194 | xha`k'`j'==4191 | xha`k'`j'==4194 | xha`k'`j'==5191 | xha`k'`j'==5194 | xha`k'`j'==6191 | xha`k'`j'==6194 | xha`k'`j'==7191 | xha`k'`j'==7194 | xha`k'`j'==8191 | xha`k'`j'==8194) local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'+1 replace xha`k'0`i'=4001 if xha`k'0`i'==9999 & xha`k'0`j'==4001 local i=`i'+1 } replace xha`k'09=4001 if xha`k'09==9999 & xha`k'10==4001 local i=10 while `i'<96{ local j=`i'+1 replace xha`k'`i'=4001 if xha`k'`i'==9999 & xha`k'`j'==4001 local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<10{ local j=`i'-1 replace xha`k'0`i'=4001 if xha`k'0`i'==9999 & xha`k'0`j'==4001 local i=`i'+1 } replace xha`k'10=4001 if xha`k'10==9999 & xha`k'09==4001 local i=11 while `i'<97{ local j=`i'-1 replace xha`k'`i'=4001 if xha`k'`i'==9999 & xha`k'`j'==4001 local i=`i'+1 } local k=`k'+1 } **AV VARIABLES **************** ** AV 1 ** local i=1 while `i'<8{ for num 1/9: gen av1_`i'_X=15 if (xha`i'0X==0 | xha`i'0X==20 | xha`i'0X==40 | xha`i'0X==55 | xha`i'0X==60 | xha`i'0X==70 | xha`i'0X==80 | xha`i'0X==99) for num 10/96: gen av1_`i'_X=15 if (xha`i'X==0 | xha`i'X==20 | xha`i'X==40 | xha`i'X==55 | xha`i'X==60 | xha`i'X==70 | xha`i'X==80 | xha`i'X==99) egen av1_`i'=rsum(av1_`i'_*) drop av1_`i'_* local i=`i'+1 } ** AV 2 ** local i=1 while `i'<8{ for num 1/9: gen av2_`i'_X=15 if (xha`i'0X==10) for num 10/96: gen av2_`i'_X=15 if (xha`i'X==10) egen av2_`i'=rsum(av2_`i'_*) drop av2_`i'_* local i=`i'+1 } ** AV 3 ** local i=1 while `i'<8{ for num 1/9: gen av3_`i'_X=15 if (xha`i'0X==50) for num 10/96: gen av3_`i'_X=15 if (xha`i'X==50) egen av3_`i'=rsum(av3_`i'_*) drop av3_`i'_* local i=`i'+1 } ** AV 4 ** local i=1 while `i'<8{ for num 1/9: gen av4_`i'_X=15 if (xha`i'0X==5000 | xha`i'0X==5010 | xha`i'0X==5020 | xha`i'0X==5021 | xha`i'0X==5030 | xha`i'0X==5041 | xha`i'0X==5050 | xha`i'0X==5060 | xha`i'0X==5070 | xha`i'0X==5075 | xha`i'0X==5099) for num 10/96: gen av4_`i'_X=15 if (xha`i'X==5000 | xha`i'X==5010 | xha`i'X==5020 | xha`i'X==5021 | xha`i'X==5030 | xha`i'X==5041 | xha`i'X==5050 | xha`i'X==5060 | xha`i'X==5070 | xha`i'X==5075 | xha`i'X==5099) egen av4_`i'=rsum(av4_`i'_*) drop av4_`i'_* local i=`i'+1 } ** AV 5 ** local i=1 while `i'<8{ for num 1/9: gen av5_`i'_X=15 if (xha`i'0X==0031 | xha`i'0X==0032 | xha`i'0X==0033 | xha`i'0X==0034 | xha`i'0X==0035 | xha`i'0X==0036 | xha`i'0X==0091 | xha`i'0X==0092 | xha`i'0X==0093 | xha`i'0X==0094 | xha`i'0X==0095 | xha`i'0X==0096 | xha`i'0X==131 | xha`i'0X==134 | xha`i'0X==191 | xha`i'0X==194 | xha`i'0X==5091 | xha`i'0X==5092 | xha`i'0X==5093 | xha`i'0X==5094 | xha`i'0X==5095 | xha`i'0X==5096 | xha`i'0X==5191 | xha`i'0X==5194) for num 10/96: gen av5_`i'_X=15 if (xha`i'X==0031 | xha`i'X==0032 | xha`i'X==0033 | xha`i'X==0034 | xha`i'X==0035 | xha`i'X==0036 | xha`i'X==0091 | xha`i'X==0092 | xha`i'X==0093 | xha`i'X==0094 | xha`i'X==0095 | xha`i'X==0096 | xha`i'X==131 | xha`i'X==134 | xha`i'X==191 | xha`i'X==194 | xha`i'X==5091 | xha`i'X==5092 | xha`i'X==5093 | xha`i'X==5094 | xha`i'X==5095 | xha`i'X==5096 | xha`i'X==5191 | xha`i'X==5194) egen av5_`i'=rsum(av5_`i'_*) drop av5_`i'_* local i=`i'+1 } ** AV 6 ** local i=1 while `i'<8{ for num 1/9: gen av6_`i'_X=15 if (xha`i'0X==1000 | xha`i'0X==1010 | xha`i'0X==1011 | xha`i'0X==1110) for num 10/96: gen av6_`i'_X=15 if (xha`i'X==1000 | xha`i'X==1010 | xha`i'X==1011 | xha`i'X==1110) egen av6_`i'=rsum(av6_`i'_*) drop av6_`i'_* local i=`i'+1 } ** AV 7** local i=1 while `i'<8{ for num 1/9: gen av7_`i'_X=15 if (xha`i'0X==1021 | xha`i'0X==1022 | xha`i'0X==1023 | xha`i'0X==1024 | xha`i'0X==1025 | xha`i'0X==1041 | xha`i'0X==1042 | xha`i'0X==1099) for num 10/96: gen av7_`i'_X=15 if (xha`i'X==1021 | xha`i'X==1022 | xha`i'X==1023 | xha`i'X==1024 | xha`i'X==1025 | xha`i'X==1041 | xha`i'X==1042 | xha`i'X==1099) egen av7_`i'=rsum(av7_`i'_*) drop av7_`i'_* local i=`i'+1 } ** AV 8** local i=1 while `i'<8{ for num 1/9: gen av8_`i'_X=15 if (xha`i'0X==1030 | xha`i'0X==1031 | xha`i'0X==1032 | xha`i'0X==1050 | xha`i'0X==1060 | xha`i'0X==1072 | xha`i'0X==1080 | xha`i'0X==4020 | xha`i'0X==6030 | xha`i'0X==6066 | xha`i'0X==9906 | xha`i'0X==1071) for num 10/96: gen av8_`i'_X=15 if (xha`i'X==1030 | xha`i'X==1031 | xha`i'X==1032 | xha`i'X==1050 | xha`i'X==1060 | xha`i'X==1072 | xha`i'X==1080 | xha`i'X==4020 | xha`i'X==6030 | xha`i'X==6066 | xha`i'X==9906 | xha`i'X==1071) egen av8_`i'=rsum(av8_`i'_*) drop av8_`i'_* local i=`i'+1 } ** AV 9** local i=1 while `i'<8{ for num 1/9: gen av9_`i'_X=15 if (xha`i'0X==1051) for num 10/96: gen av9_`i'_X=15 if (xha`i'X==1051) egen av9_`i'=rsum(av9_`i'_*) drop av9_`i'_* local i=`i'+1 } ** AV 10** local i=1 while `i'<8{ for num 1/9: gen av10_`i'_X=15 if (xha`i'0X==3001 | xha`i'0X==3002 | xha`i'0X==3003 | xha`i'0X==3010 | xha`i'0X==3011 | xha`i'0X==3012 | xha`i'0X==3013 | xha`i'0X==3014 | xha`i'0X==3015 | xha`i'0X==3016 | xha`i'0X==3040 | xha`i'0X==3041 | xha`i'0X==3042 | xha`i'0X==3050 | xha`i'0X==3051 | xha`i'0X==3060 | xha`i'0X==3070 | xha`i'0X==3099) for num 10/96: gen av10_`i'_X=15 if (xha`i'X==3001 | xha`i'X==3002 | xha`i'X==3003 | xha`i'X==3010 | xha`i'X==3011 | xha`i'X==3012 | xha`i'X==3013 | xha`i'X==3014 | xha`i'X==3015 | xha`i'X==3016 | xha`i'X==3040 | xha`i'X==3041 | xha`i'X==3042 | xha`i'X==3050 | xha`i'X==3051 | xha`i'X==3060 | xha`i'X==3070 | xha`i'X==3099) egen av10_`i'=rsum(av10_`i'_*) drop av10_`i'_* local i=`i'+1 } ** AV 11** local i=1 while `i'<8{ for num 1/9: gen av11_`i'_X=15 if (xha`i'0X==2000 | xha`i'0X==2010 | xha`i'0X==2020 | xha`i'0X==2030 | xha`i'0X==2040 | xha`i'0X==2050 | xha`i'0X==2060 | xha`i'0X==2070 | xha`i'0X==2099) for num 10/96: gen av11_`i'_X=15 if (xha`i'X==2000 | xha`i'X==2010 | xha`i'X==2020 | xha`i'X==2030 | xha`i'X==2040 | xha`i'X==2050 | xha`i'X==2060 | xha`i'X==2070 | xha`i'X==2099) egen av11_`i'=rsum(av11_`i'_*) drop av11_`i'_* local i=`i'+1 } ** AV 12** local i=1 while `i'<8{ for num 1/9: gen av12_`i'_X=15 if (xha`i'0X==1091 | xha`i'0X==1092 | xha`i'0X==1093 | xha`i'0X==1094 | xha`i'0X==1095 | xha`i'0X==1096 | xha`i'0X==1191 | xha`i'0X==1194 | xha`i'0X==2091 | xha`i'0X==2092 | xha`i'0X==2093 | xha`i'0X==2094 | xha`i'0X==2095 | xha`i'0X==2096 | xha`i'0X==2191 | xha`i'0X==2194 | xha`i'0X==3091 | xha`i'0X==3092 | xha`i'0X==3093 | xha`i'0X==3094 | xha`i'0X==3095 | xha`i'0X==3096 | xha`i'0X==3140 | xha`i'0X==3191 | xha`i'0X==3194 | xha`i'0X==4091 | xha`i'0X==4092 | xha`i'0X==4093 | xha`i'0X==4094 | xha`i'0X==4095 | xha`i'0X==4096 | xha`i'0X==4191 | xha`i'0X==4194) for num 10/96: gen av12_`i'_X=15 if (xha`i'X==1091 | xha`i'X==1092 | xha`i'X==1093 | xha`i'X==1094 | xha`i'X==1095 | xha`i'X==1096 | xha`i'X==1191 | xha`i'X==1194 | xha`i'X==2091 | xha`i'X==2092 | xha`i'X==2093 | xha`i'X==2094 | xha`i'X==2095 | xha`i'X==2096 | xha`i'X==2191 | xha`i'X==2194 | xha`i'X==3091 | xha`i'X==3092 | xha`i'X==3093 | xha`i'X==3094 | xha`i'X==3095 | xha`i'X==3096 | xha`i'X==3140 | xha`i'X==3191 | xha`i'X==3194 | xha`i'X==4091 | xha`i'X==4092 | xha`i'X==4093 | xha`i'X==4094 | xha`i'X==4095 | xha`i'X==4096 | xha`i'X==4191 | xha`i'X==4194) egen av12_`i'=rsum(av12_`i'_*) drop av12_`i'_* local i=`i'+1 } ** AV 13** local i=1 while `i'<8{ for num 1/9: gen av13_`i'_X=15 if (xha`i'0X==4000 | xha`i'0X==4001 | xha`i'0X==4080 | xha`i'0X==4099) for num 10/96: gen av13_`i'_X=15 if (xha`i'X==4000 | xha`i'X==4001 | xha`i'X==4080 | xha`i'X==4099) egen av13_`i'=rsum(av13_`i'_*) drop av13_`i'_* local i=`i'+1 } ** AV 14** local i=1 while `i'<8{ for num 1/9: gen av14_`i'_X=15 if (xha`i'0X==3020 | xha`i'0X==3030 | xha`i'0X==4010) for num 10/96: gen av14_`i'_X=15 if (xha`i'X==3020 | xha`i'X==3030 | xha`i'X==4010) egen av14_`i'=rsum(av14_`i'_*) drop av14_`i'_* local i=`i'+1 } ** AV 15** local i=1 while `i'<8{ for num 1/9: gen av15_`i'_X=15 if (xha`i'0X==4030) for num 10/96: gen av15_`i'_X=15 if (xha`i'X==4030) egen av15_`i'=rsum(av15_`i'_*) drop av15_`i'_* local i=`i'+1 } ** AV 16** local i=1 while `i'<8{ for num 1/9: gen av16_`i'_X=15 if (xha`i'0X==4050 | xha`i'0X==4060 | xha`i'0X==4070 | xha`i'0X==4710) for num 10/96: gen av16_`i'_X=15 if (xha`i'X==4050 | xha`i'X==4060 | xha`i'X==4070 | xha`i'X==4710) egen av16_`i'=rsum(av16_`i'_*) drop av16_`i'_* local i=`i'+1 } ** AV 17** local i=1 while `i'<8{ for num 1/9: gen av17_`i'_X=15 if (xha`i'0X==6091 | xha`i'0X==6092 | xha`i'0X==6093 | xha`i'0X==6094 | xha`i'0X==6095 | xha`i'0X==6096 | xha`i'0X==6191 | xha`i'0X==6194 | xha`i'0X==7091 | xha`i'0X==7092 | xha`i'0X==7093 | xha`i'0X==7094 | xha`i'0X==7095 | xha`i'0X==7096 | xha`i'0X==7191 | xha`i'0X==7194 | xha`i'0X==8091 | xha`i'0X==8092 | xha`i'0X==8093 | xha`i'0X==8094 | xha`i'0X==8095 | xha`i'0X==8096 | xha`i'0X==8191 | xha`i'0X==8194 | xha`i'0X==7820) for num 10/96: gen av17_`i'_X=15 if (xha`i'X==6091 | xha`i'X==6092 | xha`i'X==6093 | xha`i'X==6094 | xha`i'X==6095 | xha`i'X==6096 | xha`i'X==6191 | xha`i'X==6194 | xha`i'X==7091 | xha`i'X==7092 | xha`i'X==7093 | xha`i'X==7094 | xha`i'X==7095 | xha`i'X==7096 | xha`i'X==7191 | xha`i'X==7194 | xha`i'X==8091 | xha`i'X==8092 | xha`i'X==8093 | xha`i'X==8094 | xha`i'X==8095 | xha`i'X==8096 | xha`i'X==8191 | xha`i'X==8194 | xha`i'X==7820) egen av17_`i'=rsum(av17_`i'_*) drop av17_`i'_* local i=`i'+1 } ** AV 18** local i=1 while `i'<8{ for num 1/9: gen av18_`i'_X=15 if (xha`i'0X==5080 | xha`i'0X==7010 | xha`i'0X==7011 | xha`i'0X==7040 | xha`i'0X==8030 | xha`i'0X==8088 | xha`i'0X==8099) for num 10/96: gen av18_`i'_X=15 if (xha`i'X==5080 | xha`i'X==7010 | xha`i'X==7011 | xha`i'X==7040 | xha`i'X==8030 | xha`i'X==8088 | xha`i'X==8099) egen av18_`i'=rsum(av18_`i'_*) drop av18_`i'_* local i=`i'+1 } ** AV 19** local i=1 while `i'<8{ for num 1/9: gen av19_`i'_X=15 if (xha`i'0X==8000 | xha`i'0X==8010) for num 10/96: gen av19_`i'_X=15 if (xha`i'X==8000 | xha`i'X==8010) egen av19_`i'=rsum(av19_`i'_*) drop av19_`i'_* local i=`i'+1 } ** AV 20 ** local i=1 while `i'<8{ for num 1/9: gen av20_`i'_X=15 if (xha`i'0X==7000) for num 10/96: gen av20_`i'_X=15 if (xha`i'X==7000) egen av20_`i'=rsum(av20_`i'_*) drop av20_`i'_* local i=`i'+1 } ** AV 21 ** local i=1 while `i'<8{ for num 1/9: gen av21_`i'_X=15 if (xha`i'0X==8020) for num 10/96: gen av21_`i'_X=15 if (xha`i'X==8020) egen av21_`i'=rsum(av21_`i'_*) drop av21_`i'_* local i=`i'+1 } ** AV 22 ** local i=1 while `i'<8{ for num 1/9: gen av22_`i'_X=15 if (xha`i'0X==6050) for num 10/96: gen av22_`i'_X=15 if (xha`i'X==6050) egen av22_`i'=rsum(av22_`i'_*) drop av22_`i'_* local i=`i'+1 } ** AV 23 ** local i=1 while `i'<8{ for num 1/9: gen av23_`i'_X=15 if (xha`i'0X==6000 | xha`i'0X==6010 | xha`i'0X==6020 | xha`i'0X==6040 | xha`i'0X==6055 | xha`i'0X==6099 | xha`i'0X==9905) for num 10/96: gen av23_`i'_X=15 if (xha`i'X==6000 | xha`i'X==6010 | xha`i'X==6020 | xha`i'X==6040 | xha`i'X==6055 | xha`i'X==6099 | xha`i'X==9905) egen av23_`i'=rsum(av23_`i'_*) drop av23_`i'_* local i=`i'+1 } ** AV 24 ** local i=1 while `i'<8{ for num 1/9: gen av24_`i'_X=15 if (xha`i'0X==7020 | xha`i'0X==7030) for num 10/96: gen av24_`i'_X=15 if (xha`i'X==7020 | xha`i'X==7030) egen av24_`i'=rsum(av24_`i'_*) drop av24_`i'_* local i=`i'+1 } ** AV 25 ** local i=1 while `i'<8{ for num 1/9: gen av25_`i'_X=15 if (xha`i'0X==7060 | xha`i'0X==7080 | xha`i'0X==7081 | xha`i'0X==7099) for num 10/96: gen av25_`i'_X=15 if (xha`i'X==7060 | xha`i'X==7080 | xha`i'X==7081 | xha`i'X==7099) egen av25_`i'=rsum(av25_`i'_*) drop av25_`i'_* local i=`i'+1 } ** AV 26 ** local i=1 while `i'<8{ for num 1/9: gen av26_`i'_X=15 if (xha`i'0X==7070) for num 10/96: gen av26_`i'_X=15 if (xha`i'X==7070) egen av26_`i'=rsum(av26_`i'_*) drop av26_`i'_* local i=`i'+1 } ** AV 27 ** for num 1/7: gen av27_X=0 ** AV 28 ** local i=1 while `i'<8{ for num 1/9: gen av28_`i'_X=15 if (xha`i'0X==4040) for num 10/96: gen av28_`i'_X=15 if (xha`i'X==4040) egen av28_`i'=rsum(av28_`i'_*) drop av28_`i'_* local i=`i'+1 } ** AV 29 ** local i=1 while `i'<8{ for num 1/9: gen av29_`i'_X=15 if (xha`i'0X==7050) for num 10/96: gen av29_`i'_X=15 if (xha`i'X==7050) egen av29_`i'=rsum(av29_`i'_*) drop av29_`i'_* local i=`i'+1 } ** AV 30 ** local i=1 while `i'<8{ for num 1/9: gen av30_`i'_X=15 if (xha`i'0X==9001 | xha`i'0X==9002 | xha`i'0X==9003 | xha`i'0X==9004 | xha`i'0X==9048 | xha`i'0X==9049) for num 10/96: gen av30_`i'_X=15 if (xha`i'X==9001 | xha`i'X==9002 | xha`i'X==9003 | xha`i'X==9004 | xha`i'X==9048 | xha`i'X==9049) egen av30_`i'=rsum(av30_`i'_*) drop av30_`i'_* local i=`i'+1 } ** AV 31 ** local i=1 while `i'<8{ for num 1/9: gen av31_`i'_X=15 if (xha`i'0X==9101 | xha`i'0X==9102 | xha`i'0X==9103 | xha`i'0X==9104 | xha`i'0X==9105 | xha`i'0X==9106 | xha`i'0X==9148 | xha`i'0X==9149 | xha`i'0X==9150 | xha`i'0X==9151 | xha`i'0X==9152) for num 10/96: gen av31_`i'_X=15 if (xha`i'X==9101 | xha`i'X==9102 | xha`i'X==9103 | xha`i'X==9104 | xha`i'X==9105 | xha`i'X==9106 | xha`i'X==9148 | xha`i'X==9149 | xha`i'X==9150 | xha`i'X==9151 | xha`i'X==9152) egen av31_`i'=rsum(av31_`i'_*) drop av31_`i'_* local i=`i'+1 } ** AV 32 ** local i=1 while `i'<8{ for num 1/9: gen av32_`i'_X=15 if (xha`i'0X==9200) for num 10/96: gen av32_`i'_X=15 if (xha`i'X==9200) egen av32_`i'=rsum(av32_`i'_*) drop av32_`i'_* local i=`i'+1 } ** AV 33 ** local i=1 while `i'<8{ for num 1/9: gen av33_`i'_X=15 if (xha`i'0X==5001 | xha`i'0X==5011 | xha`i'0X==5031) for num 10/96: gen av33_`i'_X=15 if (xha`i'X==5001 | xha`i'X==5011 | xha`i'X==5031) egen av33_`i'=rsum(av33_`i'_*) drop av33_`i'_* local i=`i'+1 } ** AV 34 ** local i=1 while `i'<8{ for num 1/9: gen av34_`i'_X=15 if (xha`i'0X==9300) for num 10/96: gen av34_`i'_X=15 if (xha`i'X==9300) egen av34_`i'=rsum(av34_`i'_*) drop av34_`i'_* local i=`i'+1 } ** AV 35 ** local i=1 while `i'<8{ for num 1/9: gen av35_`i'_X=15 if (xha`i'0X>=9401 & xha`i'0X<=9676) for num 10/96: gen av35_`i'_X=15 if (xha`i'X>=9401 & xha`i'X<=9676) egen av35_`i'=rsum(av35_`i'_*) drop av35_`i'_* local i=`i'+1 } ** AV 36 ** local i=1 while `i'<8{ for num 1/9: gen av36_`i'_X=15 if (xha`i'0X==9910 | xha`i'0X==9998) for num 10/96: gen av36_`i'_X=15 if (xha`i'X==9910 | xha`i'X==9998) egen av36_`i'=rsum(av36_`i'_*) drop av36_`i'_* local i=`i'+1 } ** AV 37 ** local i=1 while `i'<8{ for num 1/9: gen av37_`i'_X=15 if (xha`i'0X==9902 | xha`i'0X==9904) for num 10/96: gen av37_`i'_X=15 if (xha`i'X==9902 | xha`i'X==9904) egen av37_`i'=rsum(av37_`i'_*) drop av37_`i'_* local i=`i'+1 } ** AV 38 ** local i=1 while `i'<8{ for num 1/9: gen av38_`i'_X=15 if (xha`i'0X==7051) for num 10/96: gen av38_`i'_X=15 if (xha`i'X==7051) egen av38_`i'=rsum(av38_`i'_*) drop av38_`i'_* local i=`i'+1 } ** AV 39 ** local i=1 while `i'<8{ for num 1/9: gen av39_`i'_X=15 if (xha`i'0X==8041 | xha`i'0X==8042 | xha`i'0X==8140) for num 10/96: gen av39_`i'_X=15 if (xha`i'X==8041 | xha`i'X==8042 | xha`i'X==8140) egen av39_`i'=rsum(av39_`i'_*) drop av39_`i'_* local i=`i'+1 } ** AV 40 ** local i=1 while `i'<8{ for num 1/9: gen av40_`i'_X=15 if (xha`i'0X==8040 | xha`i'0X==8043 | xha`i'0X==8050 | xha`i'0X==8060 | xha`i'0X==8070 | xha`i'0X==8071 | xha`i'0X==8072 | xha`i'0X==8073 | xha`i'0X==8081 | xha`i'0X==8082 | xha`i'0X==8121 | xha`i'0X==8141 | xha`i'0X==9901 | xha`i'0X==9903 | xha`i'0X==9907) for num 10/96: gen av40_`i'_X=15 if (xha`i'X==8040 | xha`i'X==8043 | xha`i'X==8050 | xha`i'X==8060 | xha`i'X==8070 | xha`i'X==8071 | xha`i'X==8072 | xha`i'X==8073 | xha`i'X==8081 | xha`i'X==8082 | xha`i'X==8121 | xha`i'X==8141 | xha`i'X==9901 | xha`i'X==9903 | xha`i'X==9907) egen av40_`i'=rsum(av40_`i'_*) drop av40_`i'_* local i=`i'+1 } ** AV 41 ** local i=1 while `i'<8{ for num 1/9: gen av41_`i'_X=15 if (xha`i'0X==9999 | xha`i'0X==.) for num 10/96: gen av41_`i'_X=15 if (xha`i'X==9999 | xha`i'X==.) egen av41_`i'=rsum(av41_`i'_*) drop av41_`i'_* local i=`i'+1 } ** VBLE TO CHECK THAT TIME USE IS 1440 MINUTES ** local i=1 while `i'<8{ gen tottime_`i'=av1_`i' +av2_`i' +av3_`i' +av4_`i' +av5_`i' +av6_`i' +av7_`i' +av8_`i' +av9_`i' +av10_`i' +av11_`i' +av12_`i' +av13_`i' +av14_`i' +av15_`i' +av16_`i' +av17_`i' +av18_`i' +av19_`i' +av20_`i' +av21_`i' +av22_`i' +av23_`i' +av24_`i' +av25_`i' +av26_`i' +av27_`i' +av28_`i' +av29_`i' +av30_`i' +av31_`i' +av32_`i' +av33_`i' +av34_`i' +av35_`i' +av36_`i' +av37_`i' +av38_`i' +av39_`i' +av40_`i' +av41_`i' local i=`i'+1 } //**ALL THE OBSERVATIONS HAVE 1,440 MINUTES (ONE DAY) FOR ALL DAYS (7) **/ **WE CREATE THE 69 ACTIVITY CODES ********************************* **WE FIRST CREATE A MARKER TO INDICATE THAT THE ACTIVITY HAS BEEN CONSIDERED IN THE IMPUTATION local i=1 while `i'<8{ for num 1/96: generate marker_`i'_X=0 local i=`i'+1 } *MAIN 1 ******* local i=1 while `i'<8{ for num 1/9: gen main1_`i'_X=15 if (xha`i'0X==4001) for num 10/96: gen main1_`i'_X=15 if (xha`i'X==4001) egen main1_`i'=rsum(main1_`i'_*) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main1_`i'_X==15 drop main1_`i'_* local i=`i'+1 } *MAIN 2 ******* local i=1 while `i'<8{ for num 1/9: gen main2_`i'_X=15 if (xha`i'0X==4050 | xha`i'0X==4060 | xha`i'0X==4070) for num 10/96: gen main2_`i'_X=15 if (xha`i'X==4050 | xha`i'X==4060 | xha`i'X==4070) egen main2_`i'=rsum(main2_`i'_*) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main2_`i'_X==15 drop main2_`i'_* local i=`i'+1 } *MAIN 3 ******* local i=1 while `i'<8{ for num 1/9: gen main3_`i'_X=15 if (xha`i'0X==4710) for num 10/96: gen main3_`i'_X=15 if (xha`i'X==4710) egen main3_`i'=rsum(main3_`i'_*) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main3_`i'_X==15 drop main3_`i'_* local i=`i'+1 } *MAIN 4 ******* local i=1 while `i'<8{ for num 1/9: gen main4_`i'_X=15 if (xha`i'0X==4000 | xha`i'0X==4080 | xha`i'0X==4010 | xha`i'0X==4099) for num 10/96: gen main4_`i'_X=15 if (xha`i'X==4000 | xha`i'X==4080 | xha`i'X==4010 | xha`i'X==4099) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main4_`i'_X==15 egen main4_`i'=rsum(main4_`i'_*) drop main4_`i'_* local i=`i'+1 } *MAIN 5 ******* local i=1 while `i'<8{ for num 1/9: gen main5_`i'_X=15 if (xha`i'0X==60) for num 10/96: gen main5_`i'_X=15 if (xha`i'X==60) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main5_`i'_X==15 egen main5_`i'=rsum(main5_`i'_*) drop main5_`i'_* local i=`i'+1 } *MAIN 6 ******* local i=1 while `i'<8{ for num 1/9: gen main6_`i'_X=15 if (xha`i'0X==4030) for num 10/96: gen main6_`i'_X=15 if (xha`i'X==4030) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main6_`i'_X==15 egen main6_`i'=rsum(main6_`i'_*) drop main6_`i'_* local i=`i'+1 } *MAIN 7 ******* local i=1 while `i'<8{ for num 1/9: gen main7_`i'_X=15 if (xha`i'0X==0 | xha`i'0X==20 | xha`i'0X==55 | xha`i'0X==99) for num 10/96: gen main7_`i'_X=15 if (xha`i'X==0 | xha`i'X==20 | xha`i'X==55 | xha`i'X==99) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main7_`i'_X==15 egen main7_`i'=rsum(main7_`i'_*) drop main7_`i'_* local i=`i'+1 } *MAIN 8 ******* local i=1 while `i'<8{ for num 1/9: gen main8_`i'_X=15 if (xha`i'0X==10) for num 10/96: gen main8_`i'_X=15 if (xha`i'X==10) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main8_`i'_X==15 egen main8_`i'=rsum(main8_`i'_*) drop main8_`i'_* local i=`i'+1 } *MAIN 9 ******* local i=1 while `i'<8{ for num 1/9: gen main9_`i'_X=15 if (xha`i'0X==50) for num 10/96: gen main9_`i'_X=15 if (xha`i'X==50) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main9_`i'_X==15 egen main9_`i'=rsum(main9_`i'_*) drop main9_`i'_* local i=`i'+1 } *MAIN 10 ******** for num 1/7: gen main10_X=0 *MAIN 11 ******** local i=1 while `i'<8{ for num 1/9: gen main11_`i'_X=15 if (xha`i'0X>=31 & xha`i'0X<=36) | xha`i'0X==131 | xha`i'0X==134 for num 10/96: gen main11_`i'_X=15 if (xha`i'X>=31 & xha`i'X<=36) | xha`i'X==131 | xha`i'X==134 *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main11_`i'_X==15 egen main11_`i'=rsum(main11_`i'_*) drop main11_`i'_* local i=`i'+1 } *MAIN 12 ******** local i=1 while `i'<8{ for num 1/9: gen main12_`i'_X=15 if (xha`i'0X==80) for num 10/96: gen main12_`i'_X=15 if (xha`i'X==80) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main12_`i'_X==15 egen main12_`i'=rsum(main12_`i'_*) drop main12_`i'_* local i=`i'+1 } *MAIN 13 ******** local i=1 while `i'<8{ for num 1/9: gen main13_`i'_X=15 if (xha`i'0X==40 | xha`i'0X==70) for num 10/96: gen main13_`i'_X=15 if (xha`i'X==40 | xha`i'X==70) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main13_`i'_X==15 egen main13_`i'=rsum(main13_`i'_*) drop main13_`i'_* local i=`i'+1 } *MAIN 14 ******** for num 1/7: gen main14_X=0 *MAIN 15 ******** local i=1 while `i'<8{ for num 1/9: gen main15_`i'_X=15 if (xha`i'0X==5000 | xha`i'0X==5099) for num 10/96: gen main15_`i'_X=15 if (xha`i'X==5000 | xha`i'X==5099) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main15_`i'_X==15 egen main15_`i'=rsum(main15_`i'_*) drop main15_`i'_* local i=`i'+1 } *MAIN 16 ******** local i=1 while `i'<8{ for num 1/9: gen main16_`i'_X=15 if (xha`i'0X==5001 | xha`i'0X==5011 | xha`i'0X==5021 | xha`i'0X==5031 | xha`i'0X==5075) for num 10/96: gen main16_`i'_X=15 if (xha`i'X==5001 | xha`i'X==5011 | xha`i'X==5021 | xha`i'X==5031 | xha`i'X==5075) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main16_`i'_X==15 egen main16_`i'=rsum(main16_`i'_*) drop main16_`i'_* local i=`i'+1 } *MAIN 17 ******** local i=1 while `i'<8{ for num 1/9: gen main17_`i'_X=15 if (xha`i'0X==5010 | xha`i'0X==5020 | xha`i'0X==5030 | xha`i'0X==5041 | xha`i'0X==5050 | xha`i'0X==5060 | xha`i'0X==5070) for num 10/96: gen main17_`i'_X=15 if (xha`i'X==5010 | xha`i'X==5020 | xha`i'X==5030 | xha`i'X==5041 | xha`i'X==5050 | xha`i'X==5060 | xha`i'X==5070) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main17_`i'_X==15 egen main17_`i'=rsum(main17_`i'_*) drop main17_`i'_* local i=`i'+1 } *MAIN 18 ******** local i=1 while `i'<8{ for num 1/9: gen main18_`i'_X=15 if (xha`i'0X==1000) for num 10/96: gen main18_`i'_X=15 if (xha`i'X==1000) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main18_`i'_X==15 egen main18_`i'=rsum(main18_`i'_*) drop main18_`i'_* local i=`i'+1 } *MAIN 19 ******** local i=1 while `i'<8{ for num 1/9: gen main19_`i'_X=15 if (xha`i'0X==1010 | xha`i'0X==1011 | xha`i'0X==1110) for num 10/96: gen main19_`i'_X=15 if (xha`i'X==1010 | xha`i'X==1011 | xha`i'X==1110) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main19_`i'_X==15 egen main19_`i'=rsum(main19_`i'_*) drop main19_`i'_* local i=`i'+1 } *MAIN 20 ******** local i=1 while `i'<8{ for num 1/9: gen main20_`i'_X=15 if (xha`i'0X==1021 | xha`i'0X==1022 | xha`i'0X==1023 | xha`i'0X==1024 | xha`i'0X==1025) for num 10/96: gen main20_`i'_X=15 if (xha`i'X==1021 | xha`i'X==1022 | xha`i'X==1023 | xha`i'X==1024 | xha`i'X==1025) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main20_`i'_X==15 egen main20_`i'=rsum(main20_`i'_*) drop main20_`i'_* local i=`i'+1 } *MAIN 21 ******** local i=1 while `i'<8{ for num 1/9: gen main21_`i'_X=15 if (xha`i'0X==1041 | xha`i'0X==1042 | xha`i'0X==1050) for num 10/96: gen main21_`i'_X=15 if (xha`i'X==1041 | xha`i'X==1042 | xha`i'X==1050) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main21_`i'_X==15 egen main21_`i'=rsum(main21_`i'_*) drop main21_`i'_* local i=`i'+1 } *MAIN 22 ******** local i=1 while `i'<8{ for num 1/9: gen main22_`i'_X=15 if (xha`i'0X==1030 | xha`i'0X==1031 | xha`i'0X==1032 | xha`i'0X==1060) for num 10/96: gen main22_`i'_X=15 if (xha`i'X==1030 | xha`i'X==1031 | xha`i'X==1032 | xha`i'X==1060) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main22_`i'_X==15 egen main22_`i'=rsum(main22_`i'_*) drop main22_`i'_* local i=`i'+1 } *MAIN 23 ******** local i=1 while `i'<8{ for num 1/9: gen main23_`i'_X=15 if (xha`i'0X==1080 | xha`i'0X==1099 | xha`i'0X==9906) for num 10/96: gen main23_`i'_X=15 if (xha`i'X==1080 | xha`i'X==1099 | xha`i'X==9906) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main23_`i'_X==15 egen main23_`i'=rsum(main23_`i'_*) drop main23_`i'_* local i=`i'+1 } *MAIN 24 ******** local i=1 while `i'<8{ for num 1/9: gen main24_`i'_X=15 if (xha`i'0X==3001 | xha`i'0X==3002 | xha`i'0X==3003 | xha`i'0X==3010 | xha`i'0X==3011 | xha`i'0X==3012 | xha`i'0X==3013 | xha`i'0X==3014 | xha`i'0X==3015 | xha`i'0X==3016 | xha`i'0X==3099) for num 10/96: gen main24_`i'_X=15 if (xha`i'X==3001 | xha`i'X==3002 | xha`i'X==3003 | xha`i'X==3010 | xha`i'X==3011 | xha`i'X==3012 | xha`i'X==3013 | xha`i'X==3014 | xha`i'X==3015 | xha`i'X==3016 | xha`i'X==3099) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main24_`i'_X==15 egen main24_`i'=rsum(main24_`i'_*) drop main24_`i'_* local i=`i'+1 } *MAIN 25 ******** local i=1 while `i'<8{ for num 1/9: gen main25_`i'_X=15 if (xha`i'0X==3020 | xha`i'0X==3030) for num 10/96: gen main25_`i'_X=15 if (xha`i'X==3020 | xha`i'X==3030) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main25_`i'_X==15 egen main25_`i'=rsum(main25_`i'_*) drop main25_`i'_* local i=`i'+1 } *MAIN 26 ******** local i=1 while `i'<8{ for num 1/9: gen main26_`i'_X=15 if (xha`i'0X==3040 | xha`i'0X==3041 | xha`i'0X==3042 | xha`i'0X==3050 | xha`i'0X==3051 | xha`i'0X==3060 | xha`i'0X==3070) for num 10/96: gen main26_`i'_X=15 if (xha`i'X==3040 | xha`i'X==3041 | xha`i'X==3042 | xha`i'X==3050 | xha`i'X==3051 | xha`i'X==3060 | xha`i'X==3070) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main26_`i'_X==15 egen main26_`i'=rsum(main26_`i'_*) drop main26_`i'_* local i=`i'+1 } *MAIN 27 ******** local i=1 while `i'<8{ for num 1/9: gen main27_`i'_X=15 if (xha`i'0X==1071) for num 10/96: gen main27_`i'_X=15 if (xha`i'X==1071) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main27_`i'_X==15 egen main27_`i'=rsum(main27_`i'_*) drop main27_`i'_* local i=`i'+1 } *MAIN 28 ******** local i=1 while `i'<8{ for num 1/9: gen main28_`i'_X=15 if (xha`i'0X==2000 | xha`i'0X==2010 | xha`i'0X==2060) for num 10/96: gen main28_`i'_X=15 if (xha`i'X==2000 | xha`i'X==2010 | xha`i'X==2060) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main28_`i'_X==15 egen main28_`i'=rsum(main28_`i'_*) drop main28_`i'_* local i=`i'+1 } *MAIN 29 ******** local i=1 while `i'<8{ for num 1/9: gen main29_`i'_X=15 if (xha`i'0X==2020) for num 10/96: gen main29_`i'_X=15 if (xha`i'X==2020) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main29_`i'_X==15 egen main29_`i'=rsum(main29_`i'_*) drop main29_`i'_* local i=`i'+1 } *MAIN 30 ******** local i=1 while `i'<8{ for num 1/9: gen main30_`i'_X=15 if (xha`i'0X==2030 | xha`i'0X==2040 | xha`i'0X==2050) for num 10/96: gen main30_`i'_X=15 if (xha`i'X==2030 | xha`i'X==2040 | xha`i'X==2050) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main30_`i'_X==15 egen main30_`i'=rsum(main30_`i'_*) drop main30_`i'_* local i=`i'+1 } *MAIN 31 ******** local i=1 while `i'<8{ for num 1/9: gen main31_`i'_X=15 if (xha`i'0X==2070 | xha`i'0X==2099) for num 10/96: gen main31_`i'_X=15 if (xha`i'X==2070 | xha`i'X==2099) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main31_`i'_X==15 egen main31_`i'=rsum(main31_`i'_*) drop main31_`i'_* local i=`i'+1 } *MAIN 32 ******** local i=1 while `i'<8{ for num 1/9: gen main32_`i'_X=15 if (xha`i'0X==4020 | xha`i'0X==6030 | xha`i'0X==6066) for num 10/96: gen main32_`i'_X=15 if (xha`i'X==4020 | xha`i'X==6030 | xha`i'X==6066) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main32_`i'_X==15 egen main32_`i'=rsum(main32_`i'_*) drop main32_`i'_* local i=`i'+1 } *MAIN 33 ******** local i=1 while `i'<8{ for num 1/9: gen main33_`i'_X=15 if (xha`i'0X==6000 | xha`i'0X==6010 | xha`i'0X==6020 | xha`i'0X==6055 | xha`i'0X==6099 | xha`i'0X==9905 | xha`i'0X==6040) for num 10/96: gen main33_`i'_X=15 if (xha`i'X==6000 | xha`i'X==6010 | xha`i'X==6020 | xha`i'X==6055 | xha`i'X==6099 | xha`i'X==9905 | xha`i'X==6040) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main33_`i'_X==15 egen main33_`i'=rsum(main33_`i'_*) drop main33_`i'_* local i=`i'+1 } *MAIN 34 ******** local i=1 while `i'<8{ for num 1/9: gen main34_`i'_X=15 if (xha`i'0X==6050) for num 10/96: gen main34_`i'_X=15 if (xha`i'X==6050) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main34_`i'_X==15 egen main34_`i'=rsum(main34_`i'_*) drop main34_`i'_* local i=`i'+1 } *MAIN 35 ******** local i=1 while `i'<8{ for num 1/9: gen main35_`i'_X=15 if (xha`i'0X==7099 | xha`i'0X==8088 | xha`i'0X==8099) for num 10/96: gen main35_`i'_X=15 if (xha`i'X==7099 | xha`i'X==8088 | xha`i'X==8099) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main35_`i'_X==15 egen main35_`i'=rsum(main35_`i'_*) drop main35_`i'_* local i=`i'+1 } *MAIN 36 ******** local i=1 while `i'<8{ for num 1/9: gen main36_`i'_X=15 if (xha`i'0X==7000) for num 10/96: gen main36_`i'_X=15 if (xha`i'X==7000) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main36_`i'_X==15 egen main36_`i'=rsum(main36_`i'_*) drop main36_`i'_* local i=`i'+1 } *MAIN 37 ******** local i=1 while `i'<8{ for num 1/9: gen main37_`i'_X=15 if (xha`i'0X==7020 | xha`i'0X==7030) for num 10/96: gen main37_`i'_X=15 if (xha`i'X==7020 | xha`i'X==7030) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main37_`i'_X==15 egen main37_`i'=rsum(main37_`i'_*) drop main37_`i'_* local i=`i'+1 } *MAIN 38 ******** local i=1 while `i'<8{ for num 1/9: gen main38_`i'_X=15 if (xha`i'0X==7010 | xha`i'0X==7011 | xha`i'0X==7040 | xha`i'0X==8030 | xha`i'0X==5080) for num 10/96: gen main38_`i'_X=15 if (xha`i'X==7010 | xha`i'X==7011 | xha`i'X==7040 | xha`i'X==8030 | xha`i'X==5080) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main38_`i'_X==15 egen main38_`i'=rsum(main38_`i'_*) drop main38_`i'_* local i=`i'+1 } *MAIN 39 ******** local i=1 while `i'<8{ for num 1/9: gen main39_`i'_X=15 if (xha`i'0X==7070 | xha`i'0X==4040) for num 10/96: gen main39_`i'_X=15 if (xha`i'X==7070 | xha`i'X==4040) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main39_`i'_X==15 egen main39_`i'=rsum(main39_`i'_*) drop main39_`i'_* local i=`i'+1 } *MAIN 40 ******** local i=1 while `i'<8{ for num 1/9: gen main40_`i'_X=15 if (xha`i'0X==7060 | xha`i'0X==7080 | xha`i'0X==7081) for num 10/96: gen main40_`i'_X=15 if (xha`i'X==7060 | xha`i'X==7080 | xha`i'X==7081) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main40_`i'_X==15 egen main40_`i'=rsum(main40_`i'_*) drop main40_`i'_* local i=`i'+1 } *MAIN 41 ******** local i=1 while `i'<8{ for num 1/9: gen main41_`i'_X=15 if xha`i'0X==7820 for num 10/96: gen main41_`i'_X=15 if xha`i'X==7820 *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main41_`i'_X==15 egen main41_`i'=rsum(main41_`i'_*) drop main41_`i'_* local i=`i'+1 } *MAIN 42 ******** local i=1 while `i'<8{ for num 1/9: gen main42_`i'_X=15 if (xha`i'0X==8000 | xha`i'0X==8020) for num 10/96: gen main42_`i'_X=15 if (xha`i'X==8000 | xha`i'X==8020) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main42_`i'_X==15 egen main42_`i'=rsum(main42_`i'_*) drop main42_`i'_* local i=`i'+1 } *MAIN 43 ******** for num 1/7: gen main43_X=0 *MAIN 44 ******** for num 1/7: gen main44_X=0 *MAIN 45 ******** local i=1 while `i'<8{ for num 1/9: gen main45_`i'_X=15 if (xha`i'0X==8081) for num 10/96: gen main45_`i'_X=15 if (xha`i'X==8081) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main45_`i'_X==15 egen main45_`i'=rsum(main45_`i'_*) drop main45_`i'_* local i=`i'+1 } *MAIN 46 ******** local i=1 while `i'<8{ for num 1/9: gen main46_`i'_X=15 if (xha`i'0X==1051 | xha`i'0X==8010 | xha`i'0X==1072) for num 10/96: gen main46_`i'_X=15 if (xha`i'X==1051 | xha`i'X==8010 | xha`i'X==1072) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main46_`i'_X==15 egen main46_`i'=rsum(main46_`i'_*) drop main46_`i'_* local i=`i'+1 } *MAIN 47 ******** for num 1/7: gen main47_X=0 *MAIN 48 ******** local i=1 while `i'<8{ for num 1/9: gen main48_`i'_X=15 if (xha`i'0X==7050 | xha`i'0X==7051) for num 10/96: gen main48_`i'_X=15 if (xha`i'X==7050 | xha`i'X==7051) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main48_`i'_X==15 egen main48_`i'=rsum(main48_`i'_*) drop main48_`i'_* local i=`i'+1 } *MAIN 49 ******** local i=1 while `i'<8{ for num 1/9: gen main49_`i'_X=15 if (xha`i'0X==9902 | xha`i'0X==9904) for num 10/96: gen main49_`i'_X=15 if (xha`i'X==9902 | xha`i'X==9904) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main49_`i'_X==15 egen main49_`i'=rsum(main49_`i'_*) drop main49_`i'_* local i=`i'+1 } *MAIN 50 ******** local i=1 while `i'<8{ for num 1/9: gen main50_`i'_X=15 if (xha`i'0X==8070 | xha`i'0X==8071 | xha`i'0X==8072 | xha`i'0X==8073) for num 10/96: gen main50_`i'_X=15 if (xha`i'X==8070 | xha`i'X==8071 | xha`i'X==8072 | xha`i'X==8073) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main50_`i'_X==15 egen main50_`i'=rsum(main50_`i'_*) drop main50_`i'_* local i=`i'+1 } *MAIN 51 ******** local i=1 while `i'<8{ for num 1/9: gen main51_`i'_X=15 if (xha`i'0X==8082 | xha`i'0X==9907 | xha`i'0X==9998) for num 10/96: gen main51_`i'_X=15 if (xha`i'X==8082 | xha`i'X==9907 | xha`i'X==9998) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main51_`i'_X==15 egen main51_`i'=rsum(main51_`i'_*) drop main51_`i'_* local i=`i'+1 } *MAIN 52 ******** local i=1 while `i'<8{ for num 1/9: gen main52_`i'_X=15 if (xha`i'0X==8050 | xha`i'0X==8060) for num 10/96: gen main52_`i'_X=15 if (xha`i'X==8050 | xha`i'X==8060) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main52_`i'_X==15 egen main52_`i'=rsum(main52_`i'_*) drop main52_`i'_* local i=`i'+1 } *MAIN 53 ******** local i=1 while `i'<8{ for num 1/9: gen main53_`i'_X=15 if (xha`i'0X==9903) for num 10/96: gen main53_`i'_X=15 if (xha`i'X==9903) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main53_`i'_X==15 egen main53_`i'=rsum(main53_`i'_*) drop main53_`i'_* local i=`i'+1 } *MAIN 54 ******** local i=1 while `i'<8{ for num 1/9: gen main54_`i'_X=15 if (xha`i'0X==8040 | xha`i'0X==8041 | xha`i'0X==8042 | xha`i'0X==8043 | xha`i'0X==8121 | xha`i'0X==8140 | xha`i'0X==8141) for num 10/96: gen main54_`i'_X=15 if (xha`i'X==8040 | xha`i'X==8041 | xha`i'X==8042 | xha`i'X==8043 | xha`i'X==8121 | xha`i'X==8140 | xha`i'X==8141) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main54_`i'_X==15 egen main54_`i'=rsum(main54_`i'_*) drop main54_`i'_* local i=`i'+1 } *MAIN 55 ******** local i=1 while `i'<8{ for num 1/9: gen main55_`i'_X=15 if (xha`i'0X==9910) for num 10/96: gen main55_`i'_X=15 if (xha`i'X==9910) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main55_`i'_X==15 egen main55_`i'=rsum(main55_`i'_*) drop main55_`i'_* local i=`i'+1 } *MAIN 56 ******** local i=1 while `i'<8{ for num 1/9: gen main56_`i'_X=15 if (xha`i'0X>=9300 & xha`i'0X<=9676) for num 10/96: gen main56_`i'_X=15 if (xha`i'X>=9300 & xha`i'X<=9676) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main56_`i'_X==15 egen main56_`i'=rsum(main56_`i'_*) drop main56_`i'_* local i=`i'+1 } *MAIN 57 ******** local i=1 while `i'<8{ for num 1/9: gen main57_`i'_X=15 if (xha`i'0X==9200) for num 10/96: gen main57_`i'_X=15 if (xha`i'X==9200) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main57_`i'_X==15 egen main57_`i'=rsum(main57_`i'_*) drop main57_`i'_* local i=`i'+1 } *MAIN 58 ******** local i=1 while `i'<8{ for num 1/9: gen main58_`i'_X=15 if (xha`i'0X>=9001 & xha`i'0X<=9049) for num 10/96: gen main58_`i'_X=15 if (xha`i'X>=9001 & xha`i'X<=9049) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main58_`i'_X==15 egen main58_`i'=rsum(main58_`i'_*) drop main58_`i'_* local i=`i'+1 } *MAIN 59 ******** local i=1 while `i'<8{ for num 1/9: gen main59_`i'_X=15 if (xha`i'0X>=9101 & xha`i'0X<=9152) for num 10/96: gen main59_`i'_X=15 if (xha`i'X>=9101 & xha`i'X<=9152) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main59_`i'_X==15 egen main59_`i'=rsum(main59_`i'_*) drop main59_`i'_* local i=`i'+1 } *MAIN 60 ******** for num 1/7: gen main60_X=0 *MAIN 61 ******** for num 1/7: gen main61_X=0 *MAIN 62 ******** for num 1/7: gen main62_X=0 *MAIN 63 ******** local i=1 while `i'<8{ for num 1/9: gen main63_`i'_X=15 if (xha`i'0X==91 | xha`i'0X==92 | xha`i'0X==93 | xha`i'0X==94 | xha`i'0X==95 | xha`i'0X==96 | xha`i'0X==191 | xha`i'0X==194) for num 10/96: gen main63_`i'_X=15 if (xha`i'X==91 | xha`i'X==92 | xha`i'X==93 | xha`i'X==94 | xha`i'X==95 | xha`i'X==96 | xha`i'X==191 | xha`i'X==194) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main63_`i'_X==15 egen main63_`i'=rsum(main63_`i'_*) drop main63_`i'_* local i=`i'+1 } *MAIN 64 ******** local i=1 while `i'<8{ for num 1/9: gen main64_`i'_X=15 if (xha`i'0X==5091 | xha`i'0X==5092 | xha`i'0X==5093 | xha`i'0X==5094 | xha`i'0X==5095 | xha`i'0X==5096 | xha`i'0X==5191 | xha`i'0X==5194) for num 10/96: gen main64_`i'_X=15 if (xha`i'X==5091 | xha`i'X==5092 | xha`i'X==5093 | xha`i'X==5094 | xha`i'X==5095 | xha`i'X==5096 | xha`i'X==5191 | xha`i'X==5194) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main64_`i'_X==15 egen main64_`i'=rsum(main64_`i'_*) drop main64_`i'_* local i=`i'+1 } *MAIN 65 ******** local i=1 while `i'<8{ for num 1/9: gen main65_`i'_X=15 if (xha`i'0X==6091 | xha`i'0X==6092 | xha`i'0X==6093 | xha`i'0X==6094 | xha`i'0X==6095 | xha`i'0X==6096 | xha`i'0X==6191 | xha`i'0X==6194) for num 10/96: gen main65_`i'_X=15 if (xha`i'X==6091 | xha`i'X==6092 | xha`i'X==6093 | xha`i'X==6094 | xha`i'X==6095 | xha`i'X==6096 | xha`i'X==6191 | xha`i'X==6194) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main65_`i'_X==15 egen main65_`i'=rsum(main65_`i'_*) drop main65_`i'_* local i=`i'+1 } *MAIN 66 ******** local i=1 while `i'<8{ for num 1/9: gen main66_`i'_X=15 if (xha`i'0X==2091 | xha`i'0X==2092 | xha`i'0X==2093 | xha`i'0X==2094 | xha`i'0X==2095 | xha`i'0X==2096 | xha`i'0X==2191 | xha`i'0X==2194) for num 10/96: gen main66_`i'_X=15 if (xha`i'X==2091 | xha`i'X==2092 | xha`i'X==2093 | xha`i'X==2094 | xha`i'X==2095 | xha`i'X==2096 | xha`i'X==2191 | xha`i'X==2194) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main66_`i'_X==15 egen main66_`i'=rsum(main66_`i'_*) drop main66_`i'_* local i=`i'+1 } *MAIN 67 ******** local i=1 while `i'<8{ for num 1/9: gen main67_`i'_X=15 if (xha`i'0X==1091 | xha`i'0X==1092 | xha`i'0X==1093 | xha`i'0X==1094 | xha`i'0X==1095 | xha`i'0X==1096 | xha`i'0X==1191 | xha`i'0X==1194 | xha`i'0X==3091 | xha`i'0X==3092 | xha`i'0X==3093 | xha`i'0X==3094 | xha`i'0X==3095 | xha`i'0X==3096 | xha`i'0X==3191 | xha`i'0X==3194 | xha`i'0X==4091 | xha`i'0X==4092 | xha`i'0X==4093 | xha`i'0X==4094 | xha`i'0X==4095 | xha`i'0X==4096 | xha`i'0X==4191 | xha`i'0X==4194 | xha`i'0X==3140) for num 10/96: gen main67_`i'_X=15 if (xha`i'X==1091 | xha`i'X==1092 | xha`i'X==1093 | xha`i'X==1094 | xha`i'X==1095 | xha`i'X==1096 | xha`i'X==1191 | xha`i'X==1194 | xha`i'X==3091 | xha`i'X==3092 | xha`i'X==3093 | xha`i'X==3094 | xha`i'X==3095 | xha`i'X==3096 | xha`i'X==3191 | xha`i'X==3194 | xha`i'X==4091 | xha`i'X==4092 | xha`i'X==4093 | xha`i'X==4094 | xha`i'X==4095 | xha`i'X==4096 | xha`i'X==4191 | xha`i'X==4194 | xha`i'X==3140) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main67_`i'_X==15 egen main67_`i'=rsum(main67_`i'_*) drop main67_`i'_* local i=`i'+1 } *MAIN 68 ******** local i=1 while `i'<8{ for num 1/9: gen main68_`i'_X=15 if (xha`i'0X==7091 | xha`i'0X==7092 | xha`i'0X==7093 | xha`i'0X==7094 | xha`i'0X==7095 | xha`i'0X==7096 | xha`i'0X==7191 | xha`i'0X==7194 | xha`i'0X==8091 | xha`i'0X==8092 | xha`i'0X==8093 | xha`i'0X==8094 | xha`i'0X==8095 | xha`i'0X==8096 | xha`i'0X==8191 | xha`i'0X==8194) for num 10/96: gen main68_`i'_X=15 if (xha`i'X==7091 | xha`i'X==7092 | xha`i'X==7093 | xha`i'X==7094 | xha`i'X==7095 | xha`i'X==7096 | xha`i'X==7191 | xha`i'X==7194 | xha`i'X==8091 | xha`i'X==8092 | xha`i'X==8093 | xha`i'X==8094 | xha`i'X==8095 | xha`i'X==8096 | xha`i'X==8191 | xha`i'X==8194) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main68_`i'_X==15 egen main68_`i'=rsum(main68_`i'_*) drop main68_`i'_* local i=`i'+1 } *MAIN 69 ******** local i=1 while `i'<8{ for num 1/9: gen main69_`i'_X=15 if (xha`i'0X==9999) for num 10/96: gen main69_`i'_X=15 if (xha`i'X==9999) *for num 1/96: replace marker_`i'_X=marker_`i'_X+1 if main69_`i'_X==15 egen main69_`i'=rsum(main69_`i'_*) drop main69_`i'_* local i=`i'+1 } /* local i=1 while `i'<8{ for num 1/9: tab xha`i'0X if marker_`i'_X==0 for num 10/96: tab xha`i'X if marker_`i'_X==0 local i=`i'+1 } local i=1 while `i'<8{ for num 1/9: tab xha`i'0X if marker_`i'_X>1 for num 10/96: tab xha`i'X if marker_`i'_X>1 local i=`i'+1 } */ ***CHECK THAT ALL DIARIES SUM 1440 MINUTES ****************************************** local i=1 while `i'<8{ gen check_main`i'=main1_`i'+main2_`i'+main3_`i'+main4_`i'+main5_`i'+main6_`i'+main7_`i'+main8_`i'+main9_`i'+main10_`i'+main11_`i'+main12_`i'+main13_`i'+main14_`i'+main15_`i'+main16_`i'+main17_`i'+main18_`i'+main19_`i'+main20_`i'+main21_`i'+main22_`i'+main23_`i'+main24_`i'+main25_`i'+main26_`i'+main27_`i'+main28_`i'+main29_`i'+main30_`i'+main31_`i'+main32_`i'+main33_`i'+main34_`i'+main35_`i'+main36_`i'+main37_`i'+main38_`i'+main39_`i'+main40_`i'+main41_`i'+main42_`i'+main43_`i'+main44_`i'+main45_`i'+main46_`i'+main47_`i'+main48_`i'+main49_`i'+main50_`i'+main51_`i'+main52_`i'+main53_`i'+main54_`i'+main55_`i'+main56_`i'+main57_`i'+main58_`i'+main59_`i'+main60_`i'+main61_`i'+main62_`i'+main63_`i'+main64_`i'+main65_`i'+main66_`i'+main67_`i'+main68_`i'+main69_`i' local i=`i'+1 } **FINALLY, WE CREATE THE VARIABLE FOR THE TIME SPENT WITH SPOUSE/PARTNER ************************************************************************ **NO INFORMATION ON WHO ELSE WAS PRESENT DURING THE ACTIVITY. generate sppart=-9 *2+ OR MORE OF THESE BASIC ACTIVITIES MISSING: SLEEP OR REST, EATING OR DRINKING, PERSONAL CARE, TRAVEL/EXERCISE **************************************************************************************************************** ** eating_quality ** local i=1 while `i'<8{ for num 1/9: gen eating_quality_`i'_X=15 if (xha`i'0X==060 | xha`i'0X==1000 | xha`i'0X==1010 | xha`i'0X==1011 | xha`i'0X==3001 | xha`i'0X==3003 | xha`i'0X==4030 | xha`i'0X==4040 | xha`i'0X==7060 | xha`i'0X==7070 | xha`i'0X==7080) for num 10/96: gen eating_quality_`i'_X=15 if (xha`i'X==060 | xha`i'X==1000 | xha`i'X==1010 | xha`i'X==1011 | xha`i'X==3001 | xha`i'X==3003 | xha`i'X==4030 | xha`i'X==4040 | xha`i'X==7060 | xha`i'X==7070 | xha`i'X==7080) egen eating_quality_`i'=rsum(eating_quality_`i'_*) drop eating_quality_`i'_* local i=`i'+1 } ** sleeping_quality ** local i=1 while `i'<8{ for num 1/9: gen sleeping_quality_`i'_X=15 if (xha`i'0X==4050 | xha`i'0X==4060 | xha`i'0X==4070 | xha`i'0X==4071 | xha`i'0X==9910) for num 10/96: gen sleeping_quality_`i'_X=15 if (xha`i'X==4050 | xha`i'X==4060 | xha`i'X==4070 | xha`i'X==4071 | xha`i'X==9910) egen sleeping_quality_`i'=rsum(sleeping_quality_`i'_*) drop sleeping_quality_`i'_* local i=`i'+1 } ** personal_quality ** local i=1 while `i'<8{ for num 1/9: gen personal_quality_`i'_X=15 if (xha`i'0X==4000 | xha`i'0X==4080 | xha`i'0X==3020 | xha`i'0X==3030 | xha`i'0X==4001 | xha`i'0X==4010 | xha`i'0X==4099) for num 10/96: gen personal_quality_`i'_X=15 if (xha`i'X==4000 | xha`i'X==4080 | xha`i'X==3020 | xha`i'X==3030 | xha`i'X==4001 | xha`i'X==4010 | xha`i'X==4099) egen personal_quality_`i'=rsum(personal_quality_`i'_*) drop personal_quality_`i'_* local i=`i'+1 } ** travel_quality ** local i=1 while `i'<8{ for num 1/9: gen travel_quality_`i'_X=15 if (xha`i'0X==7011 | xha`i'0X==7040 | xha`i'0X==8030 | xha`i'0X==8000 | xha`i'0X==8010 | xha`i'0X==8020) | (xha`i'0X>=031 & xha`i'0X<=036) | (xha`i'0X>=091 & xha`i'0X<=096) | (xha`i'0X>=1091 & xha`i'0X<=1096) | (xha`i'0X>=291 & xha`i'0X<=2096) | (xha`i'0X>=3091 & xha`i'0X<=3096) | (xha`i'0X>=4091 & xha`i'0X<=4096) | (xha`i'0X>=5091 & xha`i'0X<=5096) | (xha`i'0X>=6091 & xha`i'0X<=6096) | (xha`i'0X>=7091 & xha`i'0X<=7096) | (xha`i'0X>=8091 & xha`i'0X<=8096) | xha`i'0X==131 | xha`i'0X==134 | xha`i'0X==191 | xha`i'0X==194 | xha`i'0X==1191 | xha`i'0X==1194 | xha`i'0X==2191 | xha`i'0X==2194 | xha`i'0X==3191 | xha`i'0X==3194 | xha`i'0X==4191 | xha`i'0X==4194 | xha`i'0X==5191 | xha`i'0X==5194 | xha`i'0X==6191 | xha`i'0X==6194 | xha`i'0X==7191 | xha`i'0X==7194 | xha`i'0X==8191 | xha`i'0X==8194 for num 10/96: gen travel_quality_`i'_X=15 if (xha`i'X==7011 | xha`i'X==7040 | xha`i'X==8030 | xha`i'X==8000 | xha`i'X==8010 | xha`i'X==8020) | (xha`i'X>=031 & xha`i'X<=036) | (xha`i'X>=091 & xha`i'X<=096) | (xha`i'X>=1091 & xha`i'X<=1096) | (xha`i'X>=2091 & xha`i'X<=2096) | (xha`i'X>=3091 & xha`i'X<=3096) | (xha`i'X>=4091 & xha`i'X<=4096) | (xha`i'X>=5091 & xha`i'X<=5096) | (xha`i'X>=6091 & xha`i'X<=6096) | (xha`i'X>=7091 & xha`i'X<=7096) | (xha`i'X>=8091 & xha`i'X<=8096) | xha`i'X==131 | xha`i'X==134 | xha`i'X==191 | xha`i'X==194 | xha`i'X==1191 | xha`i'X==1194 | xha`i'X==2191 | xha`i'X==2194 | xha`i'X==3191 | xha`i'X==3194 | xha`i'X==4191 | xha`i'X==4194 | xha`i'X==5191 | xha`i'X==5194 | xha`i'X==6191 | xha`i'X==6194 | xha`i'X==7191 | xha`i'X==7194 | xha`i'X==8191 | xha`i'X==8194 egen travel_quality_`i'=rsum(travel_quality_`i'_*) drop travel_quality_`i'_* local i=`i'+1 } ** care_quality ** local i=1 while `i'<8{ for num 1/9: gen care_quality_`i'_X=15 if ((xha`i'0X>=2000 & xha`i'0X<=2070) | xha`i'0X==2099 | xha`i'0X==4020 | xha`i'0X==6066) for num 10/96: gen care_quality_`i'_X=15 if ((xha`i'X>=2000 & xha`i'X<=2070) | xha`i'X==2099 | xha`i'X==4020 | xha`i'X==6066) egen care_quality_`i'=rsum(care_quality_`i'_*) drop care_quality_`i'_* local i=`i'+1 } **DIARIES WITH LESS THAN SEVEN EPISODES *************************************** *WE CONSTRUCT A VARIABLE FOR COUNTING THE NUMBER OF TOTAL EPISODES FOR EACH INDIVIDUAL, IN EACH DAY *FINALLY WE IDENTIFY THOSE DIARIES WITH LESS THAN SEVEN EPISODES *WE HAVE DIFFERENTS EPISODES IF THE PRIMARY ACTIVITIES ARE DIFFERENT, SO WE HAVE TO CONSTRUCT SOME INTERMEDIATE VARIABELS TO TAKE INTO ACCOUNT THE PREVIOUS ACTIVITY local i=1 while `i'<8{ local j=1 while `j'<10{ local k=`j'+1 generate lag`i'`k'=xha`i'0`j' local j=`j'+1 } local i=`i'+1 } local i=1 while `i'<8{ local j=10 while `j'<97{ local k=`j'+1 generate lag`i'`k'=xha`i'`j' local j=`j'+1 } local i=`i'+1 } local i=1 while `i'<8{ local j=2 while `j'<10{ generate EPISODE`i'`j'=1 if xha`i'0`j'!=lag`i'`j' replace EPISODE`i'`j'=0 if EPISODE`i'`j'==. local j=`j'+1 } local j=10 while `j'<97{ generate EPISODE`i'`j'=1 if xha`i'`j'!=lag`i'`j' replace EPISODE`i'`j'=0 if EPISODE`i'`j'==. local j=`j'+1 } egen number_episodes_`i'=rsum(EPISODE`i'2 - EPISODE`i'96) replace number_episodes_`i'=number_episodes_`i'+1 local i=`i'+1 } drop EPISODE* lag* **12 EPISODES AND REPORTS ALL DAY AT HOME ***************************************** local i=1 while `i'<8{ for num 1/9: gen at_home_`i'_X=15 if (pl`i'0X==1 | pl`i'0X==2) for num 10/96: gen at_home_`i'_X=15 if (pl`i'X==1 | pl`i'X==2) local i=`i'+1 } local i=1 while `i'<8{ egen at_home_`i'=rsum(at_home_`i'_*) drop at_home_`i'_* local i=`i'+1 } **VEHICLE VARIABLE ****************** *We create a marker variable to see whether the diarist goes on bycicle local k=1 while `k'<8{ for num 1/9: generate bycicle`k'_X=1 if xha`k'0X==34 | xha`k'0X==94 | xha`k'0X==134 | xha`k'0X==1094 | xha`k'0X==2094 | xha`k'0X==3094 | xha`k'0X==4094 | xha`k'0X==5094 | xha`k'0X==6094 | xha`k'0X==7094 | xha`k'0X==8094 | xha`k'0X==194 | xha`k'0X==1194 | xha`k'0X==2194 | xha`k'0X==3194 | xha`k'0X==4194 | xha`k'0X==5194 | xha`k'0X==6194 | xha`k'0X==7194 | xha`k'0X==8194 for num 10/96: generate bycicle`k'_X=1 if xha`k'X==34 | xha`k'X==94 | xha`k'X==134 | xha`k'X==1094 | xha`k'X==2094 | xha`k'X==3094 | xha`k'X==4094 | xha`k'X==5094 | xha`k'X==6094 | xha`k'X==7094 | xha`k'X==8094 | xha`k'X==194 | xha`k'X==1194 | xha`k'X==2194 | xha`k'X==3194 | xha`k'X==4194 | xha`k'X==5194 | xha`k'X==6194 | xha`k'X==7194 | xha`k'X==8194 for num 1/96: replace bycicle`k'_X=0 if bycicle`k'_X==. egen bycicle_`k'=rsum(bycicle`k'_*) drop bycicle`k'_* local k=`k'+1 } generate bycicle=bycicle_1+bycicle_2+bycicle_3+bycicle_4+bycicle_5+bycicle_6+bycicle_7 generate vehicle=3 if s05c==1 replace vehicle=2 if vehicle==. & bycicle>=1 replace vehicle=0 if vehicle==. drop bycicle* ****************************************************************************************************************************************************************************** ****************************************************************************************************************************************************************************** *************************************************** EXPANSION OF DATASET, TO HAVE SEVEN OBSERVATIONS PER DIARIST *************************************************************** ****************************************************************************************************************************************************************************** ****************************************************************************************************************************************************************************** expand 7 sort respnr generate day=. replace day=1 if _n==1 local j=1 while `j'<=_N{ local i=`j'-1 replace day=day[`i']+1 if respnr[`i']==respnr[`j'] & _n==`j' replace day=1 if respnr[`i']!=respnr[`j'] & _n==`j' local i=`i'+1 local j=`j'+1 } generate diary=day generate id=day * WE COMPUTE EACH HARMONIXED ACTIVITY TO EACH DAY ** for num 1/41: gen avX=. for num 1/69: gen mainX=. generate eating_quality=. generate sleeping_quality=. generate travel_quality=. generate personal_quality=. generate care_quality=. generate number_episodes=. local i=1 while `i'<8{ local j=1 while `j'<42{ replace av`j'=av`j'_`i' if day==`i' local j=`j'+1 } local j=1 while `j'<70{ replace main`j'=main`j'_`i' if day==`i' local j=`j'+1 } replace eating_quality=eating_quality_`i' if day==`i' replace sleeping_quality=sleeping_quality_`i' if day==`i' replace travel_quality=travel_quality_`i' if day==`i' replace personal_quality=personal_quality_`i' if day==`i' replace care_quality=care_quality_`i' if day==`i' replace number_episodes=number_episodes_`i' if day==`i' local i=`i'+1 } egen tottime=rsum(av1-av41) **THERE ARE 15,428 OBSEVATIONS WITH 1440 MINUTES (2,204*7) gen paidetc =av1+av2+av3+av5 gen hwork=av7 gen cooking=av6 gen eating =av15 gen kidcare=av11 gen shopping=av10 gen dtravel=av12 gen otravel=av17+av18 gen perscare=av13+av16 gen eatout=av28 gen pubclubs=av26+av27 gen spectat=av20+av22+av23+av24+av25 gen asports=av19 gen walking=av21 gen visits=av29+av38 gen tvrad=av30+av31+av32 gen reading=av33+av34+av35 gen chatsetc=av36+av37 gen oddjobs=av8+av9 gen hobbies=av39+av40 gen medical=av14 gen educ=av4 gen tottime_bis=paidetc+hwork +cooking +eating +kidcare+ shopping +dtravel +otravel+ perscare+ eatout+ pubclubs+ spectat+ asports+ walking+ visits+ tvrad+ reading+ chatsetc+ oddjobs+ hobbies +medical +educ +av41 **THERE ARE 15,428 OBSEVATIONS WITH 1440 MINUTES (2,204*7) ** LOW QUALITY DIARIES ** gen badcase=. ** MISSING SEX OR AGE ** generate loss_sex_age=1 if sex<0 | age<0 replace loss_sex_age=0 if loss_sex_age==. **91+ MISSING MINUTES OF ACTIVITY ********************************* generate missing_91=1 if av41>90 replace missing_91=0 if missing_91==. ** DIARIES WITH MISSING DAY ** ****************************** **NO DIARIES WITH MISSING DAYS generate missing_day=0 ** 2+ MISSING BASIC ACTIVITIES ** replace travel_quality=1 if travel_quality>0 replace eating_quality=1 if eating_quality>0 replace sleeping_quality=1 if sleeping_quality>0 replace personal_quality=1 if personal_quality>0 replace care_quality=1 if care_quality>0 generate TOTAL_BASIC_ACTIVITIES=travel_quality+ eating_quality+ sleeping_quality+ personal_quality generate LOSS_ACTIVITIES_INTER=4-TOTAL_BASIC_ACTIVITIES generate loss_basic_activities=1 if LOSS_ACTIVITIES_INTER>=2 replace loss_basic_activities=0 if loss_basic_activities==. **WITH THE FOUR INDICATORS, WE COMPUTE THE "BADCASE" VARIABLE ************************************************************* /* BAD CASE MARKER */ replace badcase=0 if loss_sex_age==0 & missing_day==0 & missing_91==0 & number_episodes>=7 & loss_basic_activities==0 replace badcase=1 if loss_sex_age==1 & missing_day==0 & missing_91==0 & number_episodes>=7 & loss_basic_activities==0 replace badcase=2 if loss_sex_age==0 & missing_day==1 & missing_91==0 & number_episodes>=7 & loss_basic_activities==0 replace badcase=3 if loss_sex_age==0 & missing_day==0 & missing_91==1 & number_episodes>=7 & loss_basic_activities==0 replace badcase=4 if loss_sex_age==0 & missing_day==0 & missing_91==0 & number_episodes<7 & loss_basic_activities==0 replace badcase=5 if loss_sex_age==0 & missing_day==0 & missing_91==0 & number_episodes>=7 & loss_basic_activities==1 replace badcase=6 if loss_sex_age==1 & missing_day==1 & missing_91==0 & number_episodes>=7 & loss_basic_activities==0 replace badcase=7 if loss_sex_age==1 & missing_day==0 & missing_91==1 & number_episodes>=7 & loss_basic_activities==0 replace badcase=8 if loss_sex_age==1 & missing_day==0 & missing_91==0 & number_episodes<7 & loss_basic_activities==0 replace badcase=9 if loss_sex_age==1 & missing_day==0 & missing_91==0 & number_episodes>=7 & loss_basic_activities==1 replace badcase=10 if loss_sex_age==0 & missing_day==1 & missing_91==1 & number_episodes>=7 & loss_basic_activities==0 replace badcase=11 if loss_sex_age==0 & missing_day==1 & missing_91==0 & number_episodes<7 & loss_basic_activities==0 replace badcase=12 if loss_sex_age==0 & missing_day==1 & missing_91==0 & number_episodes>=7 & loss_basic_activities==1 replace badcase=13 if loss_sex_age==0 & missing_day==0 & missing_91==1 & number_episodes<7 & loss_basic_activities==0 replace badcase=14 if loss_sex_age==0 & missing_day==0 & missing_91==1 & number_episodes>=7 & loss_basic_activities==1 replace badcase=15 if loss_sex_age==0 & missing_day==0 & missing_91==0 & number_episodes<7 & loss_basic_activities==1 replace badcase=16 if loss_sex_age==1 & missing_day==1 & missing_91==1 & number_episodes>=7 & loss_basic_activities==0 replace badcase=17 if loss_sex_age==1 & missing_day==1 & missing_91==0 & number_episodes<7 & loss_basic_activities==0 replace badcase=18 if loss_sex_age==1 & missing_day==1 & missing_91==0 & number_episodes>=7 & loss_basic_activities==1 replace badcase=19 if loss_sex_age==1 & missing_day==0 & missing_91==1 & number_episodes<7 & loss_basic_activities==0 replace badcase=20 if loss_sex_age==1 & missing_day==0 & missing_91==1 & number_episodes>=7 & loss_basic_activities==1 replace badcase=21 if loss_sex_age==1 & missing_day==0 & missing_91==0 & number_episodes<7 & loss_basic_activities==1 replace badcase=22 if loss_sex_age==0 & missing_day==1 & missing_91==1 & number_episodes<7 & loss_basic_activities==0 replace badcase=23 if loss_sex_age==0 & missing_day==1 & missing_91==1 & number_episodes>=7 & loss_basic_activities==1 replace badcase=24 if loss_sex_age==0 & missing_day==1 & missing_91==0 & number_episodes<7 & loss_basic_activities==1 replace badcase=25 if loss_sex_age==0 & missing_day==0 & missing_91==1 & number_episodes<7 & loss_basic_activities==1 replace badcase=26 if loss_sex_age==1 & missing_day==1 & missing_91==1 & number_episodes<7 & loss_basic_activities==0 replace badcase=27 if loss_sex_age==1 & missing_day==1 & missing_91==1 & number_episodes>=7 & loss_basic_activities==1 replace badcase=28 if loss_sex_age==1 & missing_day==1 & missing_91==0 & number_episodes<7 & loss_basic_activities==1 replace badcase=29 if loss_sex_age==1 & missing_day==0 & missing_91==1 & number_episodes<7 & loss_basic_activities==1 replace badcase=30 if loss_sex_age==0 & missing_day==1 & missing_91==1 & number_episodes<7 & loss_basic_activities==1 replace badcase=31 if loss_sex_age==1 & missing_day==1 & missing_91==1 & number_episodes<7 & loss_basic_activities==1 /* WE HAVE THE FOLLOWING DISTRIBUTION OF BAD CASES marker of low quality cases | Freq. Percent Cum. ----------------------------------------+----------------------------------- good case | 18,976 99.30 99.30 <7 episodes only | 22 0.12 99.41 miss 2+ basic acts only | 64 0.33 99.75 <7 ep & miss 2+ basic acts | 48 0.25 100.00 ----------------------------------------+----------------------------------- Total | 19,110 100.00 */ **EXCEPTIONS TO THE MISSING BASIC ACTIVITIES *********************************************** *CARERS ******* **NO INFORMATION ON WHETHER THE PERSON IS A CARER **WE USE THE TIME DEVOTED TO ADULT CARE ACTIVITIES (MAIN32) sort persid by persid: egen sum_adult_care=sum(main32) generate carer=1 if sum_adult_care>0 replace carer=0 if sum_adult_care==0 generate carer_badcase=1 if care_quality>0 replace carer_badcase=1 if carer_badcase==. & carer==1 replace carer_badcase=0 if carer_badcase==. replace badcase=0 if carer_badcase==1 & loss_sex_age==0 & missing_day==0 & missing_91==0 & number_episodes>=7 & loss_basic_activities==1 replace badcase=0 if carer_badcase==1 & loss_sex_age==0 & missing_day==0 & missing_91==0 & number_episodes>=7 & loss_basic_activities==1 **BEING AT HOME ALL DAY *********************** gen at_home=. local i=1 while `i'<8{ replace at_home=at_home_`i' if day==`i' local i=`i'+1 } replace badcase=0 if badcase>0 & loss_sex_age==0 & missing_day==0 & missing_91==0 & number_episodes>=12 & TOTAL_BASIC_ACTIVITIES==2 & travel_quality==0 & at_home>=1000 **15+ EPISODES *************** replace badcase=0 if loss_sex_age==0 & missing_day==0 & missing_91==0 & number_episodes>=15 & TOTAL_BASIC_ACTIVITIES==2 /* We obtain the following distribution of bad diaries: marker of low quality cases | Freq. Percent Cum. ----------------------------------------+----------------------------------- good case | 9,057 98.84 98.84 <7 episodes only | 12 0.13 98.97 miss 2+ basic acts only | 42 0.46 99.43 <7 ep & miss 2+ basic acts | 52 0.57 100.00 ----------------------------------------+----------------------------------- Total | 9,163 100.00 */ ** WEIGHTS ** generate ocombwt=gewlgu 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 egen ngroupsp=max(weekwt) if badcase==0 by sex age: egen wkcount2=count(weekwt) if badcase==0 generate propwt=((wkcount2/7)/daycount2) replace propwt=0 if badcase!=0 egen mean_weight=mean(propwt) replace propwt=propwt/mean_weight **WE NOW CORRECT SOME VARIABLES replace retired=1 if age>=65 replace retired=0 if age<60 replace empstat=4 if retired==1 | student==1 replace emp=0 if retired==1 ***************************************************************************************************************************************************************************** ***************************************************************************************************************************************************************************** ******************************************************** checks of the 1440 minutes per diary ******************************************************************************* ***************************************************************************************************************************************************************************** ***************************************************************************************************************************************************************************** drop tottime tottime_bis gen tottime=av1+av2+av3+av4+av5+av6 +av7 +av8 +av9 +av10 +av11 +av12 +av13 +av14 +av15 +av16 +av17 +av18 +av19 +av20 +av21 +av22 +av23 +av24 +av25 +av26 +av27 +av28 +av29 +av30 +av31 +av32 +av33 +av34 +av35 +av36 +av37 +av38 +av39 +av40 +av41 gen tottime_bis=main1+main2+main3+main4+main5+main6+main7+main8+main9+main10+main11+main12+main13+main14+main15+main16+main17+main18+main19+main20+main21+main22+main23+main24+main25+main26+main27+main28+main29+main30+main31+main32+main33+main34+main35+main36+main37+main38+main39+main40+main41+main42+main43+main44+main45+main46+main47+main48+main49+main50+main51+main52+main53+main54+main55+main56+main57+main58+main59+main60+main61+main62+main63+main64+main65+main66+main67+main68+main69 **WITH THE TWO VARIABLES (tottime, tottime_bis) ALL DIARIES HAVE 1440 MINUTES OF ACTIVITY **WORKHRS FOR RETIRED, STUDENT AND UNEMPLOYED PEOPLE ***************************************************** gen workhrs_inter=main7 +main8 +main9 +main11 +main12 +main13 sort persid by persid: egen workhrs_bis=sum(workhrs_inter) replace workhrs_bis=workhrs_bis/60 gen workhrs_new=round(workhrs_bis) replace workhrs=workhrs_new if unemp==1 | student==1 | retired==1 replace workhrs=-7 if workhrs==0 & (unemp==1 | student==1 | retired==1) drop workhrs_* replace emp=0 if emp==-8 **REPLACE TIME USE VARIABLES NOT POSIBLE TO CREATE ************************************************** replace av27=-9 for num 10 14 43 44 47 60 61 62: replace mainX=-9 replace av27=-9 replace carer=-9 ***************************************************************************************************************************************************************************** ***************************************************************************************************************************************************************************** ************************************************************************* LABELS ******************************************************************************************** ***************************************************************************************************************************************************************************** ***************************************************************************************************************************************************************************** #delimit; lab var countrya "Country or region of survey"; lab def countrya 1 "Argentina" 2 "Austria" 3 "Australia" 4 "Belgium" 5 "Brazil" 6 "Bulgaria" 7 "Canada" 8 "China" 9 "Denmark" 10 "Estonia" 11 "Finland" 12 "France" 13 "Germany" 14 "Hungary" 15 "India" 16 "Ireland" 17 "Israel" 18 "Italy" 19 "Japan" 20 "Latvia" 21 "Lithuania" 22 "Netherlands" 23 "New Zealand" 24 "Norway" 25 "Peru" 26 "Poland" 27 "Portugal" 28 "Republic of Korea" 29 "Romania" 30 "Russia" 31 "Slovak Republic/Czechoslovakia" 32 "Slovenia/Yugoslavia" 33 "South Africa" 34 "Spain" 35 "Sweden" 36 "Turkey" 37 "United Kingdom" 38 "USA" ; lab val countrya countrya ; /*; lab var country "Old MTUS country of survey list"; lab def country 1 "Canada" 2 "Denmark" 3 "France" 4 "Netherlands" 5 "Norway" 6 "UK" 7 "USA" 8 "Hungary" 9 "West Germany - now combined with 9, use MSAMP to distinguish" 10 "Poland" 11 "Belgium" 12 "Bulgaria" 13 "Czech - old code no longer in use, see Slovak Republic" 14 "East Germany - now combined with 9, use MSAMP to distinguish" 15 "Peru" 16 "Yugoslavia - old code no longer in use, see Slovenia" 17 "Finland" 18 "Italy" 19 "Australia" 20 "Israel" 21 "Sweden" 22 "Germany" 23 "Austria" 24 "South Africa" 25 "Brazil" 26 "Estonia" 27 "India" 28 "Japan" 31 "New Zealand" 32 "Portugal" 33 "Romania" 34 "Slovenia" 35 "Spain" 36 "Lituania" 37 "Latvia" 38 "Argentina" 39 "China" 40 "Ireland" 41 "Republic of Korea" 42 "Russia" 43 "Slovak Republic" 44 "Turkey"; lab val country country; */; lab var survey "Year survey began (survey id)"; lab var swave "longitudinal study wave marker"; lab def swave 0 "not longitudinal study/case" 1 "Wave 1" 2 "Wave 2" 3 "Wave 3" 4 "Wave 4" ; lab val swave swave; lab var msamp "multiple samples in study"; lab def msamp 0 "1 sample" 1 "Szalai USA 65 sample" 2 "national USA 65 sample" 3 "original NHAPS" 4 "95 NHAPS supplement" 5 "USA 85 mail back sample" 6 "USA 85 phone interview" 7 "USA 85 personal interview" 8 "Szalai Slovenia" 9 "Szalai Serbia" 10 "West Germany" 11 "East Germany" ; lab val msamp msamp; lab var hldid "Household identifier"; lab def hldid 0 "1 person sampled per household"; lab val hldid hldid; lab var persid "Person/diarist identifier"; lab var id "Diary identifier"; lab var parntid1 "Person id 1st parent of diarist"; lab def parntid1 -9 "counld not be created" -8 "could not identify parent in hh" -7 "diarist does not live with parent"; lab val parntid1 parntid1; lab var parntid2 "Person id 2nd parent of diarist"; lab def parntid2 -9 "counld not be created" -8 "could not identify parent in hh" -7 "diarist does not live with parent"; lab val parntid2 parntid2; lab var partid "Person id of spouse or partner"; lab def partid -9 "counld not be created" -8 "could not identify partner in hh" -7 "diarist does not have partner"; lab val partid partid; lab var day "Day of week diary kept"; lab def day 1 "Sunday" 2 "Monday" 3 "Tuesday" 4 "Wednesday" 5 "Thursday" 6 "Friday" 7 "Saturday" 8 "Whole week average" 9 "Unspecified weekday" 10 "Unspecified weekend day" -8 "missing" -9 "could not be created"; lab val day day; lab var month "Month diary kept"; lab def month 1 "January" 2 "February" 3 "March" 4 "April" 5 "May" 6 "June" 7 "July" 8 "August" 9 "September" 10 "October" 11 "November" 12 "December" -8 "missing" -9 "could not be created"; lab val month month; lab var year "Year diary kept"; lab def year -8 "missing" -9 "could not be created"; lab val year year; lab var diary "Diary order"; lab def diary 1 "1st diary day" 2 "2nd diary day" 3 "3rd diary day" 4 "4th diary day" 5 "5th diary day" 6 "6th diary day" 7 "7th diary day" 8 "Weekly average" -8 "missing" -9 "could not be created"; lab val diary diary; lab var badcase "marker of low quality cases"; lab def badcase 0 "good case" 1 "miss age or sex only" 2 "miss day of week only" 3 "miss 91+ minutes only" 4 "<7 episodes only" 5 "miss 2+ basic acts only" 6 "miss age/sex + day of week" 7 "miss age/sex + 91+ min" 8 "miss age/sex + <7 episodes" 9 "miss age/sex + 2+ basic acts" 10 "miss day of week + 91+ min" 11 "miss day of week + <7 episodes" 12 "miss day of week + 2+ basic acts" 13 "miss 91+ min + <7 episodes" 14 "miss 91+ min + 2+ basic acts" 15 "<7 ep & miss 2+ basic acts" 16 "miss age/sex + day or week + 91+ min" 17 "miss age/sex + day or week + <7 episodes" 18 "miss age/sex + day or week + 2+ basic acts" 19 "miss age/sex + 91+ min + <7 eps" 20 "miss age/sex + 91+ min + 2+ basic acts" 21 "miss age/sex + 2+ basic acts + <7 eps" 22 "miss day or week + 91+ min + <7 eps" 23 "miss day or week + 91+ min + 2+ basic acts" 24 "miss day or week + 2+ basic acts + <7 eps" 25 "miss 91+ min + 2+ basic acts + <7 eps" 26 "miss age/sex + day or week + 91+ min + <7 episodes" 27 "miss age/sex + day or week + 91+ min + 2+ basic acts" 28 "miss age/sex + day or week + <7 episodes + 2+ basic acts" 29 "miss age/sex + 91+ min + <7 episodes + 2+ basic acts" 30 "day or week + 91+ min + <7 episodes + 2+ basic acts" 31 "bad on all five points"; lab val badcase badcase; lab var hhtype "Household type"; lab def hhtype 1 "1 person household" 2 "Married/cohabiting couple alone" 3 "Married/cohabiting couple + others" 4 "Other household types" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val hhtype hhtype; lab var hhldsize "# people in household"; lab def hhldsize -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val hhldsize hhldsize; lab var nchild "# child aged<18 in hhold"; lab def nchild -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val nchild nchild; lab var agekidx "Age youngest child in hhold"; lab def agekidx 1 "age 0-4" 2 "age 5-12" 3 "age 13-17" 4 "adult child" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val agekidx agekidx; lab var agekid2 "Actual age youngest child in hhold"; lab def agekid2 80 "80 or older" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val agekid2 agekid2; lab var incorig "Original household income"; lab def incorig -8 "missing"; lab val incorig incorig; lab var income "Total hhold income grouped"; lab def income 1 "lowest 25%" 2 "middle 50%" 3 "highest 25%" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val incorig incorig; lab var ownhome "owns or rents home"; lab def ownhome 1 "own outright or mortgage" 2 "rents" 3 "other" -8 "missing" -9 "could not be created"; lab val ownhome ownhome; lab var urban "Urban or rural hhold"; lab def urban 1 "urban/suburban" 2 "rural/semi-rural" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val urban urban; lab var computer "hhold has computer/internet access"; lab def computer 0 "no" 1 "yes" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val computer computer; lab var vehicle "hhold access to a private vehicle"; lab def vehicle 0 "no" 1 "animal only" 2 "non-motorised vehicle" 3 "1 car/motorcycle" 4 "2+ cars/motocycles" -8 "missing" -9 "could not be created" ; lab val vehicle vehicle; lab var sex "Sex"; lab def sex 1 "Man" 2 "Woman" -8 "missing"; lab val sex sex; lab var age "Age"; lab def age 80 "80 or older" -7 "not asked" -8 "missing"; lab val age age; lab var famstat "Individual level family status"; lab def famstat 0 "Aged 18 to 39 with no coresident children <18" 1 "Aged 18+ living with 1+ coresident children aged <5" 2 "Aged 18+ living with 1+ coresident children 5-17, none <5" 3 "Aged 40+ with no coresident children <18" 4 "Aged <18 and living with parent(s)/guardian(s)" 5 "Aged <18, living arrangement other or unknown" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val famstat famstat; lab var cphome "Unmarried child in parental home"; lab def cphome 0 "no" 1 "yes" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val cphome cphome; lab var singpar "diarist a single parent"; lab def singpar 0 "no" 1 "yes" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val singpar singpar; lab var relrefp "Relation to hhold ref person"; lab def relrefp 1 "person 1" 2 "spouse/partner" 3 "child" 4 "parent" 5 "sibling" 6 "son/daughter-in-law" 7 "parent-in-law" 8 "brother/sister-in-law" 9 "other relative" 10 "not related" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val relrefp relrefp; lab var civstat "Civic status"; lab def civstat 1 "couple (married/cohabiting/civ partnership)" 2 "not live with a spouse/partner" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val civstat civstat; lab var cohab "diarist cohabiting"; lab def cohab 0 "no, married" 1 "yes, cohabitting" -7 "not in couple" -8 "missing" -9 "could not be created"; lab val cohab cohab; lab var citizen "Diarist is citizen/national of country"; lab def citizen 0 "no, no work or vote right" 1 "no, has work or vote right" 2 "yes" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val citizen citizen; lab var empstat "employment status"; lab def empstat 1 "full-time" 2 "part-time" 3 "unknown job hours" 4 "not in paid work" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val empstat empstat; lab var emp "in paid work"; lab def emp 0 "not in paid work" 1 "in paid work" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val emp emp; lab var unemp "Unemployed"; lab def unemp 0 "no" 1 "yes" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val unemp unemp; lab var student "Student status"; lab def student 0 "not student" 1 "student" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val student student; lab var retired "Retirement status"; lab def retired 0 "not retired" 1 "retired" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val retired retired; lab var empsp "Emp status spouse/partner"; lab def empsp 1 "full-time" 2 "part-time" 3 "unknown job hours" 4 "not in paid work" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val empsp empsp; lab var empinclm "Orig monthly labour income"; lab def empinclm -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val empinclm empinclm; lab var occup "Occupation"; lab def occup 1 "management" 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"; lab val occup occup; lab var sector "Sector of employment"; lab def sector 1 "public sector" 2 "private sector" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val sector sector; lab var educa "Education-original study codes"; lab def educa 6 "doktoraal" 5 "hbo,semi univ" 4 "vhmo,mbo" 3 "ulo,mavo" 2 "lbo" 1 "lo,vglo,lavo"; lab val educa educa; lab var edtry "Harmonised education"; lab def edtry 1 "inc 2ndry or less" 2 "completed secondary" 3 "above 2ndry education" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val edtry edtry; lab var rushed "Whether diarist ususally feels rushed"; lab def rushed 0 "almost never" 1 "sometimes" 2 "often" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val rushed rushed; lab var health "Diarist's general health"; lab def health 0 "poor" 1 "fair" 2 "good" 3 "very good" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val health health; lab var carer "diarist provides adult care"; lab def carer 0 "no" 1 "yes" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val carer carer; lab var disab "has disability/l-term hlth cond"; lab def disab 0 "no" 1 "yes" -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val disab disab; lab var main1 "imputed personal or household care"; lab var main2 "sleep and naps"; lab var main3 "imputed sleep"; lab var main4 "wash, dress, care for self"; lab var main5 "meals at work or school"; lab var main6 "other meals or snacks"; lab var main7 "paid work-lab var main job (not at home)"; lab var main8 "paid work at home"; lab var main9 "second or other job not at home"; lab var main10 "unpaid work to generate household income"; lab var main11 "travel as a part of work"; lab var main12 "work breaks"; lab var main13 "other time at workplace"; lab var main14 "look for work"; lab var main15 "regular schooling, education"; lab var main16 "homework"; lab var main17 "leisure/other education or training"; lab var main18 "food preparation, cooking"; lab var main19 "set table, wash/put away dishes"; lab var main20 "cleaning"; lab var main21 "laundry, ironing, clothing repair"; lab var main22 "maintain home/vehicle"; lab var main23 "other domestic work"; lab var main24 "purchase goods"; lab var main25 "consume personal care services"; lab var main26 "consume other services"; lab var main27 "pet care (not walk dog)"; lab var main28 "physical, medical child care"; lab var main29 "teach, help with homework"; lab var main30 "read to, talk or play with child"; lab var main31 "supervise, accompany, other child care"; lab var main32 "adult care"; lab var main33 "voluntary, civic, organisational act"; lab var main34 "worship and religion"; lab var main35 "general out-of-home leisure"; lab var main36 "attend sporting event"; lab var main37 "cinema, theatre, opera, concert"; lab var main38 "other public event, venue"; lab var main39 "restaurant, café, bar, pub"; lab var main40 "party, social event, gambling"; lab var main41 "imputed time away from home"; lab var main42 "general sport or exercise"; lab var main43 "walking"; lab var main44 "cycling"; lab var main45 "other outside recreation"; lab var main46 "gardening/pick mushrooms"; lab var main47 "walk dogs"; lab var main48 "receive or visit friends"; lab var main49 "conversation (in person, phone)"; lab var main50 "other in-home social, games"; lab var main51 "general indoor leisure"; lab var main52 "art or music"; lab var main53 "correspondence (not e-lab mail)"; lab var main54 "knit, crafts or hobbies"; lab var main55 "relax, think, do nothing"; lab var main56 "read"; lab var main57 "listen to music etc"; lab var main58 "listen to radio"; lab var main59 "watch TV, video, DVD"; lab var main60 "computer games"; lab var main61 "e-lab mail, surf internet, computing"; lab var main62 "no act but recorded transport mode"; lab var main63 "travel to/from work"; lab var main64 "education travel"; lab var main65 "voluntary/civic/religious travel"; lab var main66 "child/adult care travel"; lab var main67 "shop, person/hhld care travel"; lab var main68 "other travel"; lab var main69 "no recorded activity"; forval i = 2/69{; lab def main`i' -9 "could not be created for study"; }; lab var av1 "paid work"; lab var av2 "paid work at home"; lab var av3 "second job"; lab var av4 "school/classes"; lab var av5 "travel to/from work"; lab var av6 "cook, wash up"; lab var av7 "housework"; lab var av8 "odd jobs"; lab var av9 "gardening"; lab var av10 "shopping"; lab var av11 "childcare"; lab var av12 "domestic travel"; lab var av13 "dress/personal care"; lab var av14 "consume services"; lab var av15 "meals, snacks"; lab var av16 "sleep"; lab var av17 "free time travel"; lab var av18 "excursions"; lab var av19 "active sport"; lab var av20 "passive sport"; lab var av21 "walks"; lab var av22 "religious activity"; lab var av23 "civic activity"; lab var av24 "cinema, theatre"; lab var av25 "dances, parties"; lab var av26 "social club"; lab var av27 "pub"; lab var av28 "restaurant"; lab var av29 "visit friends"; lab var av30 "listen to radio"; lab var av31 "TV, video"; lab var av32 "listen to CDs records"; lab var av33 "study"; lab var av34 "read books"; lab var av35 "read paper/magazine"; lab var av36 "relax"; lab var av37 "conversation"; lab var av38 "entertain friends"; lab var av39 "knit, sew"; lab var av40 "other leisure"; lab var av41 "missing"; forval i = 1/41{; lab def av`i' -9 "could not be created for study"; }; lab var sppart "time with spouse or partner"; lab def sppart -9 "could not be created for study"; lab val sppart sppart; lab var ocombwt "Original weight"; lab var propwt "Proposed weight"; lab var workhrs "Hours paid work last week inc overtime"; lab def workhrs -7 "not applicable/not asked" -8 "missing" -9 "could not be created"; lab val workhrs workhrs; #delimit cr **************************************************** * Stata syntax to order the W5.8 MTUS variables * **************************************************** local i=1 while `i'<8{ for num 1/69: drop mainX_`i' local i=`i'+1 } local i=1 while `i'<8{ for num 1/41: drop avX_`i' local i=`i'+1 } #delimit; keep countrya /*country*/ survey swave msamp hldid persid id parntid1 parntid2 partid day month year diary badcase hhtype workhrs hhldsize nchild agekidx agekid2 incorig income ownhome urban computer vehicle sex age famstat cphome singpar relrefp civstat cohab citizen empstat emp unemp student retired empsp empinclm occup sector educa edtry rushed health carer disab main* av* sppart ocombwt propwt respnr ; order countrya /*country*/ survey swave msamp hldid persid id parntid1 parntid2 partid day month year diary badcase hhtype hhldsize nchild agekidx agekid2 incorig income ownhome urban computer vehicle sex age famstat cphome singpar relrefp civstat cohab citizen empstat emp unemp student retired empsp workhrs empinclm occup sector educa edtry rushed health carer disab main* av* sppart ocombwt propwt ; #delimit cr compress **Since we should show the creation of all final MTUS versions, we create a intermediate version sort hldid id persid saveold Net1980W_inter.dta, replace ****************************************************************************************************************************************************************************** ****************************************************************************************************************************************************************************** ********************************************************************************* W6 VERSION ********************************************************************************* ****************************************************************************************************************************************************************************** ****************************************************************************************************************************************************************************** clear use Netherlands_1980.dta drop a* b0* b1* b2* db* xakt* gr* zo* ma* di* wo* do* vr* za* *************************************************************************** DATA PREPARATION ********************************************************************************* **IMPUTED SLEEP==4710 local k=1 while `k'<8{ local i=2 while `i'<10{ local j=`i'-1 replace xha`k'0`i'=4710 if xha`k'0`i'==9999 & (xha`k'0`j'==4050 | xha`k'0`j'==4060 | xha`k'0`j'==4070) local i=`i'+1 } replace xha`k'10=4710 if xha`k'10==9999 & (xha`k'09==4050 | xha`k'09==4060 | xha`k'09==4070) local i=11 while `i'<97{ local j=`i'-1 replace xha`k'`i'=4710 if xha`k'`i'==9999 & (xha`k'`j'==4050 | xha`k'`j'==4060 | xha`k'`j'==4070) local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'+1 replace xha`k'0`i'=4710 if xha`k'0`i'==9999 & (xha`k'0`j'==4050 | xha`k'0`j'==4060 | xha`k'0`j'==4070) local i=`i'+1 } replace xha`k'09=4710 if xha`k'09==9999 & (xha`k'10==4050 | xha`k'10==4060 | xha`k'10==4070) local i=11 while `i'<96{ local j=`i'+1 replace xha`k'`i'=4710 if xha`k'`i'==9999 & (xha`k'`j'==4050 | xha`k'`j'==4060 | xha`k'`j'==4070) local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'+1 replace xha`k'0`i'=4710 if xha`k'0`i'==9999 & xha`k'0`j'==4710 local i=`i'+1 } replace xha`k'09=4710 if xha`k'09==9999 & xha`k'10==4710 local i=11 while `i'<96{ local j=`i'+1 replace xha`k'`i'=4710 if xha`k'`i'==9999 & xha`k'`j'==4710 local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'-1 replace xha`k'0`i'=4710 if xha`k'0`i'==9999 & xha`k'0`j'==4710 local i=`i'+1 } replace xha`k'10=4710 if xha`k'10==9999 & xha`k'09==4710 local i=11 while `i'<97{ local j=`i'-1 replace xha`k'`i'=4710 if xha`k'`i'==9999 & xha`k'`j'==4710 local i=`i'+1 } local k=`k'+1 } **IMPUTED TIME AWAY FROM HOME (7820) local k=1 while `k'<8{ local i=2 while `i'<10{ replace xha`k'0`i'=7820 if xha`k'0`i'==9999 & (pl`k'0`i'==2 | pl`k'0`i'==3) local i=`i'+1 } local i=10 while `i'<97{ replace xha`k'`i'=7820 if xha`k'`i'==9999 & (pl`k'`i'==2 | pl`k'`i'==3) local i=`i'+1 } local k=`k'+1 } **IMPUTED PERSONAL AND HOUSEHOLD CARE==4001 local k=1 while `k'<8{ local i=2 while `i'<10{ local j=`i'-1 replace xha`k'0`i'=4001 if xha`k'0`i'==9999 & ((xha`k'0`j'>=31 | xha`k'0`j'<40) | (xha`k'0`j'>=91 | xha`k'0`j'<96) | (xha`k'0`j'>=131 | xha`k'0`j'<1000) | (xha`k'0`j'>=1091 | xha`k'0`j'<1099) | (xha`k'0`j'>=1191 | xha`k'0`j'<=1194) | (xha`k'0`j'>=2091 | xha`k'0`j'<2099) | (xha`k'0`j'>=3091 | xha`k'0`j'<3099) | (xha`k'0`j'>=4091 | xha`k'0`j'<4099) | (xha`k'0`j'>=5091 | xha`k'0`j'<5099) | (xha`k'0`j'>=6091 | xha`k'0`j'<6099) | (xha`k'0`j'>=7091 | xha`k'0`j'<7099) | (xha`k'0`j'>=8091 | xha`k'0`j'<8099) | xha`k'0`j'==8091 | xha`k'0`j'==2191 | xha`k'0`j'==2194 | xha`k'0`j'==3191 | xha`k'0`j'==3194 | xha`k'0`j'==4191 | xha`k'0`j'==4194 | xha`k'0`j'==5191 | xha`k'0`j'==5194 | xha`k'0`j'==6191 | xha`k'0`j'==6194 | xha`k'0`j'==7191 | xha`k'0`j'==7194 | xha`k'0`j'==8191 | xha`k'0`j'==8194) local i=`i'+1 } replace xha`k'10=4001 if xha`k'10==9999 & ((xha`k'09>=31 | xha`k'09<40) | (xha`k'09>=91 | xha`k'09<96) | (xha`k'09>=131 | xha`k'09<1000) | (xha`k'09>=1091 | xha`k'09<1099) | (xha`k'09>=1191 | xha`k'09<=1194) | (xha`k'09>=2091 | xha`k'09<2099) | (xha`k'09>=3091 | xha`k'09<3099) | (xha`k'09>=4091 | xha`k'09<4099) | (xha`k'09>=5091 | xha`k'09<5099) | (xha`k'09>=6091 | xha`k'09<6099) | (xha`k'09>=7091 | xha`k'09<7099) | (xha`k'09>=8091 | xha`k'09<8099) | xha`k'09==8091 | xha`k'09==2191 | xha`k'09==2194 | xha`k'09==3191 | xha`k'09==3194 | xha`k'09==4191 | xha`k'09==4194 | xha`k'09==5191 | xha`k'09==5194 | xha`k'09==6191 | xha`k'09==6194 | xha`k'09==7191 | xha`k'09==7194 | xha`k'09==8191 | xha`k'09==8194) local i=11 while `i'<97{ local j=`i'-1 replace xha`k'`i'=4001 if xha`k'`i'==9999 & ((xha`k'`j'>=31 | xha`k'`j'<40) | (xha`k'`j'>=91 | xha`k'`j'<96) | (xha`k'`j'>=131 | xha`k'`j'<1000) | (xha`k'`j'>=1091 | xha`k'`j'<1099) | (xha`k'`j'>=1191 | xha`k'`j'<=1194) | (xha`k'`j'>=2091 | xha`k'`j'<2099) | (xha`k'`j'>=3091 | xha`k'`j'<3099) | (xha`k'`j'>=4091 | xha`k'`j'<4099) | (xha`k'`j'>=5091 | xha`k'`j'<5099) | (xha`k'`j'>=6091 | xha`k'`j'<6099) | (xha`k'`j'>=7091 | xha`k'`j'<7099) | (xha`k'`j'>=8091 | xha`k'`j'<8099) | xha`k'`j'==8091 | xha`k'`j'==2191 | xha`k'`j'==2194 | xha`k'`j'==3191 | xha`k'`j'==3194 | xha`k'`j'==4191 | xha`k'`j'==4194 | xha`k'`j'==5191 | xha`k'`j'==5194 | xha`k'`j'==6191 | xha`k'`j'==6194 | xha`k'`j'==7191 | xha`k'`j'==7194 | xha`k'`j'==8191 | xha`k'`j'==8194) local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'+1 replace xha`k'0`i'=4001 if xha`k'0`i'==9999 & ((xha`k'0`j'>=31 | xha`k'0`j'<40) | (xha`k'0`j'>=91 | xha`k'0`j'<96) | (xha`k'0`j'>=131 | xha`k'0`j'<1000) | (xha`k'0`j'>=1091 | xha`k'0`j'<1099) | (xha`k'0`j'>=1191 | xha`k'0`j'<=1194) | (xha`k'0`j'>=2091 | xha`k'0`j'<2099) | (xha`k'0`j'>=3091 | xha`k'0`j'<3099) | (xha`k'0`j'>=4091 | xha`k'0`j'<4099) | (xha`k'0`j'>=5091 | xha`k'0`j'<5099) | (xha`k'0`j'>=6091 | xha`k'0`j'<6099) | (xha`k'0`j'>=7091 | xha`k'0`j'<7099) | (xha`k'0`j'>=8091 | xha`k'0`j'<8099) | xha`k'0`j'==8091 | xha`k'0`j'==2191 | xha`k'0`j'==2194 | xha`k'0`j'==3191 | xha`k'0`j'==3194 | xha`k'0`j'==4191 | xha`k'0`j'==4194 | xha`k'0`j'==5191 | xha`k'0`j'==5194 | xha`k'0`j'==6191 | xha`k'0`j'==6194 | xha`k'0`j'==7191 | xha`k'0`j'==7194 | xha`k'0`j'==8191 | xha`k'0`j'==8194) local i=`i'+1 } replace xha`k'10=4001 if xha`k'10==9999 & ((xha`k'11>=31 | xha`k'11<40) | (xha`k'11>=91 | xha`k'11<96) | (xha`k'11>=131 | xha`k'11<1000) | (xha`k'11>=1091 | xha`k'11<1099) | (xha`k'11>=1191 | xha`k'11<=1194) | (xha`k'11>=2091 | xha`k'11<2099) | (xha`k'11>=3091 | xha`k'11<3099) | (xha`k'11>=4091 | xha`k'11<4099) | (xha`k'11>=5091 | xha`k'11<5099) | (xha`k'11>=6091 | xha`k'11<6099) | (xha`k'11>=7091 | xha`k'11<7099) | (xha`k'11>=8091 | xha`k'11<8099) | xha`k'11==8091 | xha`k'11==2191 | xha`k'11==2194 | xha`k'11==3191 | xha`k'11==3194 | xha`k'11==4191 | xha`k'11==4194 | xha`k'11==5191 | xha`k'11==5194 | xha`k'11==6191 | xha`k'11==6194 | xha`k'11==7191 | xha`k'11==7194 | xha`k'11==8191 | xha`k'11==8194) local i=11 while `i'<96{ local j=`i'+1 replace xha`k'`i'=4001 if xha`k'`i'==9999 & ((xha`k'`j'>=31 | xha`k'`j'<40) | (xha`k'`j'>=91 | xha`k'`j'<96) | (xha`k'`j'>=131 | xha`k'`j'<1000) | (xha`k'`j'>=1091 | xha`k'`j'<1099) | (xha`k'`j'>=1191 | xha`k'`j'<=1194) | (xha`k'`j'>=2091 | xha`k'`j'<2099) | (xha`k'`j'>=3091 | xha`k'`j'<3099) | (xha`k'`j'>=4091 | xha`k'`j'<4099) | (xha`k'`j'>=5091 | xha`k'`j'<5099) | (xha`k'`j'>=6091 | xha`k'`j'<6099) | (xha`k'`j'>=7091 | xha`k'`j'<7099) | (xha`k'`j'>=8091 | xha`k'`j'<8099) | xha`k'`j'==8091 | xha`k'`j'==2191 | xha`k'`j'==2194 | xha`k'`j'==3191 | xha`k'`j'==3194 | xha`k'`j'==4191 | xha`k'`j'==4194 | xha`k'`j'==5191 | xha`k'`j'==5194 | xha`k'`j'==6191 | xha`k'`j'==6194 | xha`k'`j'==7191 | xha`k'`j'==7194 | xha`k'`j'==8191 | xha`k'`j'==8194) local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<9{ local j=`i'+1 replace xha`k'0`i'=4001 if xha`k'0`i'==9999 & xha`k'0`j'==4001 local i=`i'+1 } replace xha`k'09=4001 if xha`k'09==9999 & xha`k'10==4001 local i=10 while `i'<96{ local j=`i'+1 replace xha`k'`i'=4001 if xha`k'`i'==9999 & xha`k'`j'==4001 local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<10{ local j=`i'-1 replace xha`k'0`i'=4001 if xha`k'0`i'==9999 & xha`k'0`j'==4001 local i=`i'+1 } replace xha`k'10=4001 if xha`k'10==9999 & xha`k'09==4001 local i=11 while `i'<97{ local j=`i'-1 replace xha`k'`i'=4001 if xha`k'`i'==9999 & xha`k'`j'==4001 local i=`i'+1 } local k=`k'+1 } **VARIABLES FOR THE W6 VERSION ****************************** ****************************** /* THERE ARE SEVERAL PROBLEMS: 1 NO INFORMATION ON WHO ELSE IS PRESENT 2 for the SECONDARY activities you need only enter those SECONDARY activities which have a number beginning with the figure 9. Other SECONDARY activities art not important in this survey. */ ** WHO ELSE ACTIVITIES ********************** generate alone=-9 generate child=-9 generate sppart=-9 generate oad=-9 **WE NOW HAVE TO IDENTIFY THE EPISODES, WITH CHANGES IN ACTIVITIES ************************************************ local k=1 while `k'<8{ generate new_episode`k'_1=1 for num 2/96: generate new_episode`k'_X=. local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<10{ local j=`i'-1 replace new_episode`k'_`i'=1 if (xha`k'0`i'!=xha`k'0`j') | pl`k'0`i'!=pl`k'0`i' local i=`i'+1 } replace new_episode`k'_10=1 if (xha`k'10!=xha`k'09) | (pl`k'10!=pl`k'09) local i=11 while `i'<97{ local j=`i'-1 replace new_episode`k'_`i'=1 if (xha`k'`i'!=xha`k'`j') | (pl`k'`i'!=pl`k'`i') local i=`i'+1 } egen number_episodes`k'=rsum(new_episode`k'_1-new_episode`k'_96) local k=`k'+1 } **WE GENERATE THE MAXIMUM NUMBER OF EPISODES IN THE SURVEY ********************************************************** egen number_max_episodes_inter=rmax(number_episodes1-number_episodes7) egen number_max_episodes=max(number_max_episodes_inter) sort respnr **WE CREATE THE NUMBER MAX OF EPISODES TO IDENTIFY THE ACTIVITY IN EACH EPISODE ******************************************************************************* local k=1 while `k'<8{ generate number_episode`k'_1=1 for num 2/96: generate number_episode`k'_X=. for num 2/96: replace new_episode`k'_X=0 if new_episode`k'_X==. local i=2 while `i'<10{ local j=`i'-1 replace number_episode`k'_`i'=number_episode`k'_`j'+new_episode`k'_`i' local i=`i'+1 } replace number_episode`k'_10=number_episode`k'_9+new_episode`k'_10 local i=11 while `i'<97{ local j=`i'-1 replace number_episode`k'_`i'=number_episode`k'_`j'+new_episode`k'_`i' local i=`i'+1 } local k=`k'+1 } **DURATION OF ACTIVITIES ************************ local k=1 while `k'<8{ for num 1/96: generate duration_episode`k'_X=. replace duration_episode`k'_1=15 local i=2 while `i'<10{ local j=`i'-1 replace duration_episode`k'_`i'=15 if number_episode`k'_`i'!=number_episode`k'_`j' replace duration_episode`k'_`i'=15+duration_episode`k'_`j' if number_episode`k'_`i'==number_episode`k'_`j' local i=`i'+1 } replace duration_episode`k'_10=15 if number_episode`k'_10!=number_episode`k'_9 replace duration_episode`k'_10=15+duration_episode`k'_9 if number_episode`k'_10==number_episode`k'_9 local i=11 while `i'<97{ local j=`i'-1 replace duration_episode`k'_`i'=15 if number_episode`k'_`i'!=number_episode`k'_`j' replace duration_episode`k'_`i'=15+duration_episode`k'_`j' if number_episode`k'_`i'==number_episode`k'_`j' local i=`i'+1 } local i=2 while `i'<10{ local j=`i'-1 replace duration_episode`k'_`j'=. if number_episode`k'_`i'==number_episode`k'_`j' local i=`i'+1 } replace duration_episode`k'_9=. if number_episode`k'_10==number_episode`k'_9 local 1=11 while `i'<97{ local j=`i'-1 replace duration_episode`k'_`j'=. if number_episode`k'_`i'==number_episode`k'_`j' local i=`i'+1 } local k=`k'+1 } **COMPUTE THE DURATION OF EACH EPISODE TO EACH EPISODE ****************************************************** local k=1 while `k'<8{ local i=1 while `i'<=number_max_episodes{ generate time`k'_`i'=. local j=1 while `j'<97{ replace time`k'_`i'=duration_episode`k'_`j' if number_episode`k'_`j'==`i' & duration_episode`k'_`j'!=. local j=`j'+1 } local i=`i'+1 } local k=`k'+1 } **TIME TRANSCURRED AT THE BEGINNIG OF THE ACTIVITY ************************************************** local k=1 while `k'<8{ generate time_transcurred`k'_1=0 local i=2 while `i'<=number_max_episodes{ generate time_transcurred`k'_`i'=. local j=`i'-1 replace time_transcurred`k'_`i'=time`k'_`j'+time_transcurred`k'_`j' local i=`i'+1 } generate clockst`k'_1=0 local i=2 while `i'<=number_max_episodes{ generate clockst`k'_`i'=. local j=0 while `j'<=1440{ local m=`j'+60 replace clockst`k'_`i'=(`j'/60)+(time_transcurred`k'_`i'-`j'+1)/100 if (time_transcurred`k'_`i'>=`j' & time_transcurred`k'_`i'<`m') local j=`j'+60 format clockst`k'_`i' %9.2f } local i=`i'+1 } local k=`k'+1 } **TIME TRANSCURRED AT THE END OF THE ACTIVITY ********************************************* local k=1 while `k'<8{ local i=1 while `i'=31 & xha`k'0`i'<=36) | xha`k'0`i'==131 | xha`k'0`i'==134 replace main_inter`k'_`i'=12 if xha`k'0`i'==80 replace main_inter`k'_`i'=13 if xha`k'0`i'==40 | xha`k'0`i'==70 replace main_inter`k'_`i'=15 if xha`k'0`i'==5000 | xha`k'0`i'==5099 replace main_inter`k'_`i'=16 if xha`k'0`i'==5001 | xha`k'0`i'==5011 | xha`k'0`i'==5021 | xha`k'0`i'==5031 | xha`k'0`i'==5075 replace main_inter`k'_`i'=17 if xha`k'0`i'==5010 | xha`k'0`i'==5020 | xha`k'0`i'==5030 | xha`k'0`i'==5041 | xha`k'0`i'==5050 | xha`k'0`i'==5060 | xha`k'0`i'==5070 replace main_inter`k'_`i'=18 if xha`k'0`i'==1000 replace main_inter`k'_`i'=19 if xha`k'0`i'==1010 | xha`k'0`i'==1011 | xha`k'0`i'==1110 replace main_inter`k'_`i'=20 if xha`k'0`i'==1021 | xha`k'0`i'==1022 | xha`k'0`i'==1023 | xha`k'0`i'==1024 | xha`k'0`i'==1025 replace main_inter`k'_`i'=21 if xha`k'0`i'==1041 | xha`k'0`i'==1042 | xha`k'0`i'==1050 replace main_inter`k'_`i'=22 if xha`k'0`i'==1030 | xha`k'0`i'==1031 | xha`k'0`i'==1032 | xha`k'0`i'==1060 replace main_inter`k'_`i'=23 if xha`k'0`i'==1080 | xha`k'0`i'==1099 | xha`k'0`i'==9906 replace main_inter`k'_`i'=24 if xha`k'0`i'==3001 | xha`k'0`i'==3002 | xha`k'0`i'==3003 | xha`k'0`i'==3010 | xha`k'0`i'==3011 | xha`k'0`i'==3012 | xha`k'0`i'==3013 | xha`k'0`i'==3014 | xha`k'0`i'==3015 | xha`k'0`i'==3016 | xha`k'0`i'==3099 replace main_inter`k'_`i'=25 if xha`k'0`i'==3020 | xha`k'0`i'==3030 replace main_inter`k'_`i'=26 if xha`k'0`i'==3040 | xha`k'0`i'==3041 | xha`k'0`i'==3042 | xha`k'0`i'==3050 | xha`k'0`i'==3051 | xha`k'0`i'==3060 | xha`k'0`i'==3070 replace main_inter`k'_`i'=27 if xha`k'0`i'==1071 replace main_inter`k'_`i'=28 if xha`k'0`i'==2000 | xha`k'0`i'==2010 | xha`k'0`i'==2060 replace main_inter`k'_`i'=29 if xha`k'0`i'==2020 replace main_inter`k'_`i'=30 if xha`k'0`i'==2030 | xha`k'0`i'==2040 | xha`k'0`i'==2050 replace main_inter`k'_`i'=31 if xha`k'0`i'==2070 | xha`k'0`i'==2099 replace main_inter`k'_`i'=32 if xha`k'0`i'==4020 | xha`k'0`i'==6030 | xha`k'0`i'==6066 replace main_inter`k'_`i'=33 if xha`k'0`i'==6000 | xha`k'0`i'==6010 | xha`k'0`i'==6020 | xha`k'0`i'==6055 | xha`k'0`i'==6099 | xha`k'0`i'==9905 | xha`k'0`i'==6040 replace main_inter`k'_`i'=34 if xha`k'0`i'==6050 replace main_inter`k'_`i'=35 if xha`k'0`i'==7099 | xha`k'0`i'==8088 | xha`k'0`i'==8099 replace main_inter`k'_`i'=36 if xha`k'0`i'==7000 replace main_inter`k'_`i'=37 if xha`k'0`i'==7020 | xha`k'0`i'==7030 replace main_inter`k'_`i'=38 if xha`k'0`i'==7010 | xha`k'0`i'==7011 | xha`k'0`i'==7040 | xha`k'0`i'==8030 | xha`k'0`i'==5080 replace main_inter`k'_`i'=39 if xha`k'0`i'==7070 | xha`k'0`i'==4040 replace main_inter`k'_`i'=40 if xha`k'0`i'==7060 | xha`k'0`i'==7080 | xha`k'0`i'==7081 replace main_inter`k'_`i'=41 if xha`k'0`i'==7820 replace main_inter`k'_`i'=42 if xha`k'0`i'==8000 | xha`k'0`i'==8020 replace main_inter`k'_`i'=45 if xha`k'0`i'==8081 replace main_inter`k'_`i'=46 if xha`k'0`i'==1051 | xha`k'0`i'==8010 | xha`k'0`i'==1072 replace main_inter`k'_`i'=48 if xha`k'0`i'==7050 | xha`k'0`i'==7051 replace main_inter`k'_`i'=49 if xha`k'0`i'==9902 | xha`k'0`i'==9904 replace main_inter`k'_`i'=50 if xha`k'0`i'==8070 | xha`k'0`i'==8071 | xha`k'0`i'==8072 | xha`k'0`i'==8073 replace main_inter`k'_`i'=51 if xha`k'0`i'==8082 | xha`k'0`i'==9907 | xha`k'0`i'==9998 replace main_inter`k'_`i'=52 if xha`k'0`i'==8050 | xha`k'0`i'==8060 replace main_inter`k'_`i'=53 if xha`k'0`i'==9903 replace main_inter`k'_`i'=54 if xha`k'0`i'==8040 | xha`k'0`i'==8041 | xha`k'0`i'==8042 | xha`k'0`i'==8043 | xha`k'0`i'==8140 | xha`k'0`i'==8141 replace main_inter`k'_`i'=55 if xha`k'0`i'==9910 replace main_inter`k'_`i'=56 if (xha`k'0`i'>=9300 & xha`k'0`i'<=9676) replace main_inter`k'_`i'=57 if xha`k'0`i'==9200 replace main_inter`k'_`i'=58 if (xha`k'0`i'>=9001 & xha`k'0`i'<=9049) replace main_inter`k'_`i'=59 if (xha`k'0`i'>=9101 & xha`k'0`i'<=9152) replace main_inter`k'_`i'=63 if xha`k'0`i'==91 | xha`k'0`i'==92 | xha`k'0`i'==93 | xha`k'0`i'==94 | xha`k'0`i'==95 | xha`k'0`i'==96 | xha`k'0`i'==191 | xha`k'0`i'==194 replace main_inter`k'_`i'=64 if xha`k'0`i'==5091 | xha`k'0`i'==5092 | xha`k'0`i'==5093 | xha`k'0`i'==5094 | xha`k'0`i'==5095 | xha`k'0`i'==5096 | xha`k'0`i'==5191 | xha`k'0`i'==5194 replace main_inter`k'_`i'=65 if xha`k'0`i'==6091 | xha`k'0`i'==6092 | xha`k'0`i'==6093 | xha`k'0`i'==6094 | xha`k'0`i'==6095 | xha`k'0`i'==6096 | xha`k'0`i'==6191 | xha`k'0`i'==6194 replace main_inter`k'_`i'=66 if xha`k'0`i'==2091 | xha`k'0`i'==2092 | xha`k'0`i'==2093 | xha`k'0`i'==2094 | xha`k'0`i'==2095 | xha`k'0`i'==2096 | xha`k'0`i'==2191 | xha`k'0`i'==2194 replace main_inter`k'_`i'=67 if xha`k'0`i'==1091 | xha`k'0`i'==1092 | xha`k'0`i'==1093 | xha`k'0`i'==1094 | xha`k'0`i'==1095 | xha`k'0`i'==1096 | xha`k'0`i'==1191 | xha`k'0`i'==1194 | xha`k'0`i'==3091 | xha`k'0`i'==3092 | xha`k'0`i'==3093 | xha`k'0`i'==3094 | xha`k'0`i'==3095 | xha`k'0`i'==3096 | xha`k'0`i'==3191 | xha`k'0`i'==3194 | xha`k'0`i'==4091 | xha`k'0`i'==4092 | xha`k'0`i'==4093 | xha`k'0`i'==4094 | xha`k'0`i'==4095 | xha`k'0`i'==4096 | xha`k'0`i'==4191 | xha`k'0`i'==4194 | xha`k'0`i'==3140 replace main_inter`k'_`i'=68 if xha`k'0`i'==7091 | xha`k'0`i'==7092 | xha`k'0`i'==7093 | xha`k'0`i'==7094 | xha`k'0`i'==7095 | xha`k'0`i'==7096 | xha`k'0`i'==7191 | xha`k'0`i'==7194 | xha`k'0`i'==8091 | xha`k'0`i'==8092 | xha`k'0`i'==8093 | xha`k'0`i'==8094 | xha`k'0`i'==8095 | xha`k'0`i'==8096 | xha`k'0`i'==8191 | xha`k'0`i'==8194 replace main_inter`k'_`i'=69 if xha`k'0`i'==9999 local i=`i'+1 } local i=10 while `i'<97{ generate main_inter`k'_`i'=1 if xha`k'`i'==4001 replace main_inter`k'_`i'=2 if xha`k'`i'==4050 | xha`k'`i'==4060 | xha`k'`i'==4070 replace main_inter`k'_`i'=3 if xha`k'`i'==4710 replace main_inter`k'_`i'=4 if xha`k'`i'==4000 | xha`k'`i'==4080 | xha`k'`i'==4010 | xha`k'`i'==4099 replace main_inter`k'_`i'=5 if xha`k'`i'==60 replace main_inter`k'_`i'=6 if xha`k'`i'==4030 replace main_inter`k'_`i'=7 if xha`k'`i'==0 | xha`k'`i'==20 | xha`k'`i'==55 | xha`k'`i'==99 replace main_inter`k'_`i'=8 if xha`k'`i'==10 replace main_inter`k'_`i'=9 if xha`k'`i'==50 replace main_inter`k'_`i'=11 if (xha`k'`i'>=31 & xha`k'`i'<=36) | xha`k'`i'==131 | xha`k'`i'==134 replace main_inter`k'_`i'=12 if xha`k'`i'==80 replace main_inter`k'_`i'=13 if xha`k'`i'==40 | xha`k'`i'==70 replace main_inter`k'_`i'=15 if xha`k'`i'==5000 | xha`k'`i'==5099 replace main_inter`k'_`i'=16 if xha`k'`i'==5001 | xha`k'`i'==5011 | xha`k'`i'==5021 | xha`k'`i'==5031 | xha`k'`i'==5075 replace main_inter`k'_`i'=17 if xha`k'`i'==5010 | xha`k'`i'==5020 | xha`k'`i'==5030 | xha`k'`i'==5041 | xha`k'`i'==5050 | xha`k'`i'==5060 | xha`k'`i'==5070 replace main_inter`k'_`i'=18 if xha`k'`i'==1000 replace main_inter`k'_`i'=19 if xha`k'`i'==1010 | xha`k'`i'==1011 | xha`k'`i'==1110 replace main_inter`k'_`i'=20 if xha`k'`i'==1021 | xha`k'`i'==1022 | xha`k'`i'==1023 | xha`k'`i'==1024 | xha`k'`i'==1025 replace main_inter`k'_`i'=21 if xha`k'`i'==1041 | xha`k'`i'==1042 | xha`k'`i'==1050 replace main_inter`k'_`i'=22 if xha`k'`i'==1030 | xha`k'`i'==1031 | xha`k'`i'==1032 | xha`k'`i'==1060 replace main_inter`k'_`i'=23 if xha`k'`i'==1080 | xha`k'`i'==1099 | xha`k'`i'==9906 replace main_inter`k'_`i'=24 if xha`k'`i'==3001 | xha`k'`i'==3002 | xha`k'`i'==3003 | xha`k'`i'==3010 | xha`k'`i'==3011 | xha`k'`i'==3012 | xha`k'`i'==3013 | xha`k'`i'==3014 | xha`k'`i'==3015 | xha`k'`i'==3016 | xha`k'`i'==3099 replace main_inter`k'_`i'=25 if xha`k'`i'==3020 | xha`k'`i'==3030 replace main_inter`k'_`i'=26 if xha`k'`i'==3040 | xha`k'`i'==3041 | xha`k'`i'==3042 | xha`k'`i'==3050 | xha`k'`i'==3051 | xha`k'`i'==3060 | xha`k'`i'==3070 replace main_inter`k'_`i'=27 if xha`k'`i'==1071 replace main_inter`k'_`i'=28 if xha`k'`i'==2000 | xha`k'`i'==2010 | xha`k'`i'==2060 replace main_inter`k'_`i'=29 if xha`k'`i'==2020 replace main_inter`k'_`i'=30 if xha`k'`i'==2030 | xha`k'`i'==2040 | xha`k'`i'==2050 replace main_inter`k'_`i'=31 if xha`k'`i'==2070 | xha`k'`i'==2099 replace main_inter`k'_`i'=32 if xha`k'`i'==4020 | xha`k'`i'==6030 | xha`k'`i'==6066 replace main_inter`k'_`i'=33 if xha`k'`i'==6000 | xha`k'`i'==6010 | xha`k'`i'==6020 | xha`k'`i'==6055 | xha`k'`i'==6099 | xha`k'`i'==9905 | xha`k'`i'==6040 replace main_inter`k'_`i'=34 if xha`k'`i'==6050 replace main_inter`k'_`i'=35 if xha`k'`i'==7099 | xha`k'`i'==8088 | xha`k'`i'==8099 replace main_inter`k'_`i'=36 if xha`k'`i'==7000 replace main_inter`k'_`i'=37 if xha`k'`i'==7020 | xha`k'`i'==7030 replace main_inter`k'_`i'=38 if xha`k'`i'==7010 | xha`k'`i'==7011 | xha`k'`i'==7040 | xha`k'`i'==8030 | xha`k'`i'==5080 replace main_inter`k'_`i'=39 if xha`k'`i'==7070 | xha`k'`i'==4040 replace main_inter`k'_`i'=40 if xha`k'`i'==7060 | xha`k'`i'==7080 | xha`k'`i'==7081 replace main_inter`k'_`i'=41 if xha`k'`i'==7820 replace main_inter`k'_`i'=42 if xha`k'`i'==8000 | xha`k'`i'==8020 | xha`k'`i'==8088 | xha`k'`i'==8099 replace main_inter`k'_`i'=45 if xha`k'`i'==8081 replace main_inter`k'_`i'=46 if xha`k'`i'==1051 | xha`k'`i'==8010 | xha`k'`i'==1072 replace main_inter`k'_`i'=48 if xha`k'`i'==7050 | xha`k'`i'==7051 replace main_inter`k'_`i'=49 if xha`k'`i'==9902 | xha`k'`i'==9904 replace main_inter`k'_`i'=50 if xha`k'`i'==8070 | xha`k'`i'==8071 | xha`k'`i'==8072 | xha`k'`i'==8073 replace main_inter`k'_`i'=51 if xha`k'`i'==8082 | xha`k'`i'==9907 | xha`k'`i'==9998 replace main_inter`k'_`i'=52 if xha`k'`i'==8050 | xha`k'`i'==8060 replace main_inter`k'_`i'=53 if xha`k'`i'==9903 replace main_inter`k'_`i'=54 if xha`k'`i'==8040 | xha`k'`i'==8041 | xha`k'`i'==8042 | xha`k'`i'==8043 | xha`k'`i'==8140 | xha`k'`i'==8141 replace main_inter`k'_`i'=55 if xha`k'`i'==9910 replace main_inter`k'_`i'=56 if (xha`k'`i'>=9300 & xha`k'`i'<=9676) replace main_inter`k'_`i'=57 if xha`k'`i'==9200 replace main_inter`k'_`i'=58 if (xha`k'`i'>=9001 & xha`k'`i'<=9049) replace main_inter`k'_`i'=59 if (xha`k'`i'>=9101 & xha`k'`i'<=9152) replace main_inter`k'_`i'=63 if xha`k'`i'==91 | xha`k'`i'==92 | xha`k'`i'==93 | xha`k'`i'==94 | xha`k'`i'==95 | xha`k'`i'==96 | xha`k'`i'==191 | xha`k'`i'==194 replace main_inter`k'_`i'=64 if xha`k'`i'==5091 | xha`k'`i'==5092 | xha`k'`i'==5093 | xha`k'`i'==5094 | xha`k'`i'==5095 | xha`k'`i'==5096 | xha`k'`i'==5191 | xha`k'`i'==5194 replace main_inter`k'_`i'=65 if xha`k'`i'==6091 | xha`k'`i'==6092 | xha`k'`i'==6093 | xha`k'`i'==6094 | xha`k'`i'==6095 | xha`k'`i'==6096 | xha`k'`i'==6191 | xha`k'`i'==6194 replace main_inter`k'_`i'=66 if xha`k'`i'==2091 | xha`k'`i'==2092 | xha`k'`i'==2093 | xha`k'`i'==2094 | xha`k'`i'==2095 | xha`k'`i'==2096 | xha`k'`i'==2191 | xha`k'`i'==2194 replace main_inter`k'_`i'=67 if xha`k'`i'==1091 | xha`k'`i'==1092 | xha`k'`i'==1093 | xha`k'`i'==1094 | xha`k'`i'==1095 | xha`k'`i'==1096 | xha`k'`i'==1191 | xha`k'`i'==1194 | xha`k'`i'==3091 | xha`k'`i'==3092 | xha`k'`i'==3093 | xha`k'`i'==3094 | xha`k'`i'==3095 | xha`k'`i'==3096 | xha`k'`i'==3191 | xha`k'`i'==3194 | xha`k'`i'==4091 | xha`k'`i'==4092 | xha`k'`i'==4093 | xha`k'`i'==4094 | xha`k'`i'==4095 | xha`k'`i'==4096 | xha`k'`i'==4191 | xha`k'`i'==4194 | xha`k'`i'==3140 replace main_inter`k'_`i'=68 if xha`k'`i'==7091 | xha`k'`i'==7092 | xha`k'`i'==7093 | xha`k'`i'==7094 | xha`k'`i'==7095 | xha`k'`i'==7096 | xha`k'`i'==7191 | xha`k'`i'==7194 | xha`k'`i'==8091 | xha`k'`i'==8092 | xha`k'`i'==8093 | xha`k'`i'==8094 | xha`k'`i'==8095 | xha`k'`i'==8096 | xha`k'`i'==8191 | xha`k'`i'==8194 replace main_inter`k'_`i'=69 if xha`k'`i'==9999 local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ generate main`k'_1=main_inter`k'_1 local i=2 while `i'<=number_max_episodes{ generate main`k'_`i'=. local l=`i'-1 local j=2 while `j'<97{ replace main`k'_`i'=main_inter`k'_`j' if number_episode`k'_`j'==`i' & main`k'_`i'==. & main`k'_`l'!=. local j=`j'+1 } local i=`i'+1 } local k=`k'+1 } drop main_inter* **AV ACTIVITIES *************** local k=1 while `k'<8{ local i=1 while `i'<10{ generate av_inter`k'_`i'=1 if xha`k'0`i'==0 | xha`k'0`i'==20 | xha`k'0`i'==40 | xha`k'0`i'==55 | xha`k'0`i'==60 | xha`k'0`i'==70 | xha`k'0`i'==80 | xha`k'0`i'==99 replace av_inter`k'_`i'=2 if xha`k'0`i'==10 replace av_inter`k'_`i'=3 if xha`k'0`i'==50 replace av_inter`k'_`i'=4 if xha`k'0`i'==5000 | xha`k'0`i'==5010 | xha`k'0`i'==5020 | xha`k'0`i'==5021 | xha`k'0`i'==5030 | xha`k'0`i'==5041 | xha`k'0`i'==5050 | xha`k'0`i'==5060 | xha`k'0`i'==5070 | xha`k'0`i'==5075 | xha`k'0`i'==5099 replace av_inter`k'_`i'=5 if xha`k'0`i'==0031 | xha`k'0`i'==0032 | xha`k'0`i'==0033 | xha`k'0`i'==0034 | xha`k'0`i'==0035 | xha`k'0`i'==0036 | xha`k'0`i'==0091 | xha`k'0`i'==0092 | xha`k'0`i'==0093 | xha`k'0`i'==0094 | xha`k'0`i'==0095 | xha`k'0`i'==0096 | xha`k'0`i'==131 | xha`k'0`i'==134 | xha`k'0`i'==191 | xha`k'0`i'==194 | xha`k'0`i'==5091 | xha`k'0`i'==5092 | xha`k'0`i'==5093 | xha`k'0`i'==5094 | xha`k'0`i'==5095 | xha`k'0`i'==5096 | xha`k'0`i'==5191 | xha`k'0`i'==5194 replace av_inter`k'_`i'=6 if xha`k'0`i'==1000 | xha`k'0`i'==1010 | xha`k'0`i'==1011 | xha`k'0`i'==1110 replace av_inter`k'_`i'=7 if xha`k'0`i'==1021 | xha`k'0`i'==1022 | xha`k'0`i'==1023 | xha`k'0`i'==1024 | xha`k'0`i'==1025 | xha`k'0`i'==1041 | xha`k'0`i'==1042 | xha`k'0`i'==1099 replace av_inter`k'_`i'=8 if xha`k'0`i'==1030 | xha`k'0`i'==1031 | xha`k'0`i'==1032 | xha`k'0`i'==1050 | xha`k'0`i'==1060 | xha`k'0`i'==1072 | xha`k'0`i'==1080 | xha`k'0`i'==4020 | xha`k'0`i'==6030 | xha`k'0`i'==6066 | xha`k'0`i'==9906 | xha`k'0`i'==1071 replace av_inter`k'_`i'=9 if xha`k'0`i'==1051 replace av_inter`k'_`i'=10 if xha`k'0`i'==3001 | xha`k'0`i'==3002 | xha`k'0`i'==3003 | xha`k'0`i'==3010 | xha`k'0`i'==3011 | xha`k'0`i'==3012 | xha`k'0`i'==3013 | xha`k'0`i'==3014 | xha`k'0`i'==3015 | xha`k'0`i'==3016 | xha`k'0`i'==3040 | xha`k'0`i'==3041 | xha`k'0`i'==3042 | xha`k'0`i'==3050 | xha`k'0`i'==3051 | xha`k'0`i'==3060 | xha`k'0`i'==3070 | xha`k'0`i'==3099 replace av_inter`k'_`i'=11 if xha`k'0`i'==2000 | xha`k'0`i'==2010 | xha`k'0`i'==2020 | xha`k'0`i'==2030 | xha`k'0`i'==2040 | xha`k'0`i'==2050 | xha`k'0`i'==2060 | xha`k'0`i'==2070 | xha`k'0`i'==2099 replace av_inter`k'_`i'=12 if xha`k'0`i'==1091 | xha`k'0`i'==1092 | xha`k'0`i'==1093 | xha`k'0`i'==1094 | xha`k'0`i'==1095 | xha`k'0`i'==1096 | xha`k'0`i'==1191 | xha`k'0`i'==1194 | xha`k'0`i'==2091 | xha`k'0`i'==2092 | xha`k'0`i'==2093 | xha`k'0`i'==2094 | xha`k'0`i'==2095 | xha`k'0`i'==2096 | xha`k'0`i'==2191 | xha`k'0`i'==2194 | xha`k'0`i'==3091 | xha`k'0`i'==3092 | xha`k'0`i'==3093 | xha`k'0`i'==3094 | xha`k'0`i'==3095 | xha`k'0`i'==3096 | xha`k'0`i'==3140 | xha`k'0`i'==3191 | xha`k'0`i'==3194 | xha`k'0`i'==4091 | xha`k'0`i'==4092 | xha`k'0`i'==4093 | xha`k'0`i'==4094 | xha`k'0`i'==4095 | xha`k'0`i'==4096 | xha`k'0`i'==4191 | xha`k'0`i'==4194 replace av_inter`k'_`i'=13 if xha`k'0`i'==4000 | xha`k'0`i'==4001 | xha`k'0`i'==4080 | xha`k'0`i'==4099 replace av_inter`k'_`i'=14 if xha`k'0`i'==3020 | xha`k'0`i'==3030 | xha`k'0`i'==4010 replace av_inter`k'_`i'=15 if xha`k'0`i'==4030 replace av_inter`k'_`i'=16 if xha`k'0`i'==4050 | xha`k'0`i'==4060 | xha`k'0`i'==4070 | xha`k'0`i'==4710 replace av_inter`k'_`i'=17 if xha`k'0`i'==6091 | xha`k'0`i'==6092 | xha`k'0`i'==6093 | xha`k'0`i'==6094 | xha`k'0`i'==6095 | xha`k'0`i'==6096 | xha`k'0`i'==6191 | xha`k'0`i'==6194 | xha`k'0`i'==7091 | xha`k'0`i'==7092 | xha`k'0`i'==7093 | xha`k'0`i'==7094 | xha`k'0`i'==7095 | xha`k'0`i'==7096 | xha`k'0`i'==7191 | xha`k'0`i'==7194 | xha`k'0`i'==8091 | xha`k'0`i'==8092 | xha`k'0`i'==8093 | xha`k'0`i'==8094 | xha`k'0`i'==8095 | xha`k'0`i'==8096 | xha`k'0`i'==8191 | xha`k'0`i'==8194 | xha`k'0`i'==7820 replace av_inter`k'_`i'=18 if xha`k'0`i'==5080 | xha`k'0`i'==7010 | xha`k'0`i'==7011 | xha`k'0`i'==7040 | xha`k'0`i'==8030 | xha`k'0`i'==8088 | xha`k'0`i'==8099 replace av_inter`k'_`i'=19 if xha`k'0`i'==8000 | xha`k'0`i'==8010 replace av_inter`k'_`i'=20 if xha`k'0`i'==7000 replace av_inter`k'_`i'=21 if xha`k'0`i'==8020 replace av_inter`k'_`i'=22 if xha`k'0`i'==6050 replace av_inter`k'_`i'=23 if xha`k'0`i'==6000 | xha`k'0`i'==6010 | xha`k'0`i'==6020 | xha`k'0`i'==6040 | xha`k'0`i'==6055 | xha`k'0`i'==6099 | xha`k'0`i'==9905 replace av_inter`k'_`i'=24 if xha`k'0`i'==7020 | xha`k'0`i'==7030 replace av_inter`k'_`i'=25 if xha`k'0`i'==7060 | xha`k'0`i'==7080 | xha`k'0`i'==7081 | xha`k'0`i'==7099 replace av_inter`k'_`i'=26 if xha`k'0`i'==7070 replace av_inter`k'_`i'=28 if xha`k'0`i'==4040 replace av_inter`k'_`i'=29 if xha`k'0`i'==7050 replace av_inter`k'_`i'=30 if xha`k'0`i'==9001 | xha`k'0`i'==9002 | xha`k'0`i'==9003 | xha`k'0`i'==9004 | xha`k'0`i'==9048 | xha`k'0`i'==9049 replace av_inter`k'_`i'=31 if xha`k'0`i'==9101 | xha`k'0`i'==9102 | xha`k'0`i'==9103 | xha`k'0`i'==9104 | xha`k'0`i'==9105 | xha`k'0`i'==9106 | xha`k'0`i'==9148 | xha`k'0`i'==9149 | xha`k'0`i'==9150 | xha`k'0`i'==9151 | xha`k'0`i'==9152 replace av_inter`k'_`i'=32 if xha`k'0`i'==9200 replace av_inter`k'_`i'=33 if xha`k'0`i'==5001 | xha`k'0`i'==5011 | xha`k'0`i'==5031 replace av_inter`k'_`i'=34 if xha`k'0`i'==9300 replace av_inter`k'_`i'=35 if (xha`k'0`i'>=9401 & xha`k'0`i'<=9676) replace av_inter`k'_`i'=36 if xha`k'0`i'==9910 | xha`k'0`i'==9998 replace av_inter`k'_`i'=37 if xha`k'0`i'==9902 | xha`k'0`i'==9904 replace av_inter`k'_`i'=38 if xha`k'0`i'==7051 replace av_inter`k'_`i'=39 if xha`k'0`i'==8041 | xha`k'0`i'==8042 | xha`k'0`i'==8140 replace av_inter`k'_`i'=40 if xha`k'0`i'==8040 | xha`k'0`i'==8043 | xha`k'0`i'==8050 | xha`k'0`i'==8060 | xha`k'0`i'==8070 | xha`k'0`i'==8071 | xha`k'0`i'==8072 | xha`k'0`i'==8073 | xha`k'0`i'==8081 | xha`k'0`i'==8082 | xha`k'0`i'==8121 | xha`k'0`i'==8141 | xha`k'0`i'==9901 | xha`k'0`i'==9903 | xha`k'0`i'==9907 replace av_inter`k'_`i'=41 if xha`k'0`i'==9999 | xha`k'0`i'==. local i=`i'+1 } local i=10 while `i'<97{ generate av_inter`k'_`i'=1 if xha`k'`i'==0 | xha`k'`i'==20 | xha`k'`i'==40 | xha`k'`i'==55 | xha`k'`i'==60 | xha`k'`i'==70 | xha`k'`i'==80 | xha`k'`i'==99 replace av_inter`k'_`i'=2 if xha`k'`i'==10 replace av_inter`k'_`i'=3 if xha`k'`i'==50 replace av_inter`k'_`i'=4 if xha`k'`i'==5000 | xha`k'`i'==5010 | xha`k'`i'==5020 | xha`k'`i'==5021 | xha`k'`i'==5030 | xha`k'`i'==5041 | xha`k'`i'==5050 | xha`k'`i'==5060 | xha`k'`i'==5070 | xha`k'`i'==5075 | xha`k'`i'==5099 replace av_inter`k'_`i'=5 if xha`k'`i'==0031 | xha`k'`i'==0032 | xha`k'`i'==0033 | xha`k'`i'==0034 | xha`k'`i'==0035 | xha`k'`i'==0036 | xha`k'`i'==0091 | xha`k'`i'==0092 | xha`k'`i'==0093 | xha`k'`i'==0094 | xha`k'`i'==0095 | xha`k'`i'==0096 | xha`k'`i'==131 | xha`k'`i'==134 | xha`k'`i'==191 | xha`k'`i'==194 | xha`k'`i'==5091 | xha`k'`i'==5092 | xha`k'`i'==5093 | xha`k'`i'==5094 | xha`k'`i'==5095 | xha`k'`i'==5096 | xha`k'`i'==5191 | xha`k'`i'==5194 replace av_inter`k'_`i'=6 if xha`k'`i'==1000 | xha`k'`i'==1010 | xha`k'`i'==1011 | xha`k'`i'==1110 replace av_inter`k'_`i'=7 if xha`k'`i'==1021 | xha`k'`i'==1022 | xha`k'`i'==1023 | xha`k'`i'==1024 | xha`k'`i'==1025 | xha`k'`i'==1041 | xha`k'`i'==1042 | xha`k'`i'==1099 replace av_inter`k'_`i'=8 if xha`k'`i'==1030 | xha`k'`i'==1031 | xha`k'`i'==1032 | xha`k'`i'==1050 | xha`k'`i'==1060 | xha`k'`i'==1072 | xha`k'`i'==1080 | xha`k'`i'==4020 | xha`k'`i'==6030 | xha`k'`i'==6066 | xha`k'`i'==9906 | xha`k'`i'==1071 replace av_inter`k'_`i'=9 if xha`k'`i'==1051 replace av_inter`k'_`i'=10 if xha`k'`i'==3001 | xha`k'`i'==3002 | xha`k'`i'==3003 | xha`k'`i'==3010 | xha`k'`i'==3011 | xha`k'`i'==3012 | xha`k'`i'==3013 | xha`k'`i'==3014 | xha`k'`i'==3015 | xha`k'`i'==3016 | xha`k'`i'==3040 | xha`k'`i'==3041 | xha`k'`i'==3042 | xha`k'`i'==3050 | xha`k'`i'==3051 | xha`k'`i'==3060 | xha`k'`i'==3070 | xha`k'`i'==3099 replace av_inter`k'_`i'=11 if xha`k'`i'==2000 | xha`k'`i'==2010 | xha`k'`i'==2020 | xha`k'`i'==2030 | xha`k'`i'==2040 | xha`k'`i'==2050 | xha`k'`i'==2060 | xha`k'`i'==2070 | xha`k'`i'==2099 replace av_inter`k'_`i'=12 if xha`k'`i'==1091 | xha`k'`i'==1092 | xha`k'`i'==1093 | xha`k'`i'==1094 | xha`k'`i'==1095 | xha`k'`i'==1096 | xha`k'`i'==1191 | xha`k'`i'==1194 | xha`k'`i'==2091 | xha`k'`i'==2092 | xha`k'`i'==2093 | xha`k'`i'==2094 | xha`k'`i'==2095 | xha`k'`i'==2096 | xha`k'`i'==2191 | xha`k'`i'==2194 | xha`k'`i'==3091 | xha`k'`i'==3092 | xha`k'`i'==3093 | xha`k'`i'==3094 | xha`k'`i'==3095 | xha`k'`i'==3096 | xha`k'`i'==3140 | xha`k'`i'==3191 | xha`k'`i'==3194 | xha`k'`i'==4091 | xha`k'`i'==4092 | xha`k'`i'==4093 | xha`k'`i'==4094 | xha`k'`i'==4095 | xha`k'`i'==4096 | xha`k'`i'==4191 | xha`k'`i'==4194 replace av_inter`k'_`i'=13 if xha`k'`i'==4000 | xha`k'`i'==4001 | xha`k'`i'==4080 | xha`k'`i'==4099 replace av_inter`k'_`i'=14 if xha`k'`i'==3020 | xha`k'`i'==3030 | xha`k'`i'==4010 replace av_inter`k'_`i'=15 if xha`k'`i'==4030 replace av_inter`k'_`i'=16 if xha`k'`i'==4050 | xha`k'`i'==4060 | xha`k'`i'==4070 | xha`k'`i'==4710 replace av_inter`k'_`i'=17 if xha`k'`i'==6091 | xha`k'`i'==6092 | xha`k'`i'==6093 | xha`k'`i'==6094 | xha`k'`i'==6095 | xha`k'`i'==6096 | xha`k'`i'==6191 | xha`k'`i'==6194 | xha`k'`i'==7091 | xha`k'`i'==7092 | xha`k'`i'==7093 | xha`k'`i'==7094 | xha`k'`i'==7095 | xha`k'`i'==7096 | xha`k'`i'==7191 | xha`k'`i'==7194 | xha`k'`i'==8091 | xha`k'`i'==8092 | xha`k'`i'==8093 | xha`k'`i'==8094 | xha`k'`i'==8095 | xha`k'`i'==8096 | xha`k'`i'==8191 | xha`k'`i'==8194 | xha`k'`i'==7820 replace av_inter`k'_`i'=18 if xha`k'`i'==5080 | xha`k'`i'==7010 | xha`k'`i'==7011 | xha`k'`i'==7040 | xha`k'`i'==8030 | xha`k'`i'==8088 | xha`k'`i'==8099 replace av_inter`k'_`i'=19 if xha`k'`i'==8000 | xha`k'`i'==8010 replace av_inter`k'_`i'=20 if xha`k'`i'==7000 replace av_inter`k'_`i'=21 if xha`k'`i'==8020 replace av_inter`k'_`i'=22 if xha`k'`i'==6050 replace av_inter`k'_`i'=23 if xha`k'`i'==6000 | xha`k'`i'==6010 | xha`k'`i'==6020 | xha`k'`i'==6040 | xha`k'`i'==6055 | xha`k'`i'==6099 | xha`k'`i'==9905 replace av_inter`k'_`i'=24 if xha`k'`i'==7020 | xha`k'`i'==7030 replace av_inter`k'_`i'=25 if xha`k'`i'==7060 | xha`k'`i'==7080 | xha`k'`i'==7081 | xha`k'`i'==7099 replace av_inter`k'_`i'=26 if xha`k'`i'==7070 replace av_inter`k'_`i'=28 if xha`k'`i'==4040 replace av_inter`k'_`i'=29 if xha`k'`i'==7050 replace av_inter`k'_`i'=30 if xha`k'`i'==9001 | xha`k'`i'==9002 | xha`k'`i'==9003 | xha`k'`i'==9004 | xha`k'`i'==9048 | xha`k'`i'==9049 replace av_inter`k'_`i'=31 if xha`k'`i'==9101 | xha`k'`i'==9102 | xha`k'`i'==9103 | xha`k'`i'==9104 | xha`k'`i'==9105 | xha`k'`i'==9106 | xha`k'`i'==9148 | xha`k'`i'==9149 | xha`k'`i'==9150 | xha`k'`i'==9151 | xha`k'`i'==9152 replace av_inter`k'_`i'=32 if xha`k'`i'==9200 replace av_inter`k'_`i'=33 if xha`k'`i'==5001 | xha`k'`i'==5011 | xha`k'`i'==5031 replace av_inter`k'_`i'=34 if xha`k'`i'==9300 replace av_inter`k'_`i'=35 if (xha`k'`i'>=9401 & xha`k'`i'<=9676) replace av_inter`k'_`i'=36 if xha`k'`i'==9910 | xha`k'`i'==9998 replace av_inter`k'_`i'=37 if xha`k'`i'==9902 | xha`k'`i'==9904 replace av_inter`k'_`i'=38 if xha`k'`i'==7051 replace av_inter`k'_`i'=39 if xha`k'`i'==8041 | xha`k'`i'==8042 | xha`k'`i'==8140 replace av_inter`k'_`i'=40 if xha`k'`i'==8040 | xha`k'`i'==8043 | xha`k'`i'==8050 | xha`k'`i'==8060 | xha`k'`i'==8070 | xha`k'`i'==8071 | xha`k'`i'==8072 | xha`k'`i'==8073 | xha`k'`i'==8081 | xha`k'`i'==8082 | xha`k'`i'==8121 | xha`k'`i'==8141 | xha`k'`i'==9901 | xha`k'`i'==9903 | xha`k'`i'==9907 replace av_inter`k'_`i'=41 if xha`k'`i'==9999 | xha`k'`i'==. local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ generate av`k'_1=av_inter`k'_1 local i=2 while `i'<=number_max_episodes{ generate av`k'_`i'=. local l=`i'-1 local j=2 while `j'<97{ replace av`k'_`i'=av_inter`k'_`j' if number_episode`k'_`j'==`i' & av`k'_`i'==. & av`k'_`l'!=. local j=`j'+1 } local i=`i'+1 } local k=`k'+1 } drop av_inter* **SECONDARY ACTIVITY ******************** local k=1 while `k'<8{ local i=1 while `i'<10{ generate sec_inter`k'_`i'=69 if na`k'0`i'==1 | na`k'0`i'==. replace sec_inter`k'_`i'=59 if na`k'0`i'==2 | na`k'0`i'==3 | na`k'0`i'==6 | na`k'0`i'==4 replace sec_inter`k'_`i'=58 if na`k'0`i'==5 local i=`i'+1 } local i=10 while `i'<97{ generate sec_inter`k'_`i'=69 if na`k'`i'==1 | na`k'`i'==. replace sec_inter`k'_`i'=59 if na`k'`i'==2 | na`k'`i'==3 | na`k'`i'==6 | na`k'`i'==4 replace sec_inter`k'_`i'=58 if na`k'`i'==5 local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ generate sec`k'_1=sec_inter`k'_1 local i=2 while `i'<=number_max_episodes{ generate sec`k'_`i'=. local l=`i'-1 local j=2 while `j'<97{ replace sec`k'_`i'=sec_inter`k'_`j' if number_episode`k'_`j'==`i' & sec`k'_`i'==. & sec`k'_`l'!=. local j=`j'+1 } local i=`i'+1 } local k=`k'+1 } drop sec_inter* **MODE OF TRANSPORT VARIABLES ***************************** local k=1 while `k'<8{ local i=1 while `i'<10{ generate mtrav_inter`k'_`i'=-8 if xha`k'0`i'==9999 replace mtrav_inter`k'_`i'=1 if xha`k'0`i'==31 | xha`k'0`i'==32 | xha`k'0`i'==33 | xha`k'0`i'==91 | xha`k'0`i'==92 | xha`k'0`i'==93 | xha`k'0`i'==131 | xha`k'0`i'==191 | xha`k'0`i'==1091 | xha`k'0`i'==1092 | xha`k'0`i'==1093 | xha`k'0`i'==1191 | xha`k'0`i'==2091 | xha`k'0`i'==2092 | xha`k'0`i'==2093 | xha`k'0`i'==2191 | xha`k'0`i'==3091 | xha`k'0`i'==3092 | xha`k'0`i'==3093 | xha`k'0`i'==3191 | xha`k'0`i'==4091 | xha`k'0`i'==4092 | xha`k'0`i'==4093 | xha`k'0`i'==4191 | xha`k'0`i'==5091 | xha`k'0`i'==5092 | xha`k'0`i'==5093 | xha`k'0`i'==5191 | xha`k'0`i'==6091 | xha`k'0`i'==6092 | xha`k'0`i'==6093 | xha`k'0`i'==6191 | xha`k'0`i'==7091 | xha`k'0`i'==7092 | xha`k'0`i'==7093 | xha`k'0`i'==7191 | xha`k'0`i'==8091 | xha`k'0`i'==8092 | xha`k'0`i'==8093 | xha`k'0`i'==8191 replace mtrav_inter`k'_`i'=2 if xha`k'0`i'==36 | xha`k'0`i'==96 | xha`k'0`i'==1096 | xha`k'0`i'==2096 | xha`k'0`i'==3096 | xha`k'0`i'==4096 | xha`k'0`i'==5096 | xha`k'0`i'==6096 | xha`k'0`i'==7096 | xha`k'0`i'==8096 replace mtrav_inter`k'_`i'=3 if xha`k'0`i'==35 | xha`k'0`i'==95 | xha`k'0`i'==1095 | xha`k'0`i'==2095 | xha`k'0`i'==3095 | xha`k'0`i'==4095 | xha`k'0`i'==5095 | xha`k'0`i'==6095 | xha`k'0`i'==7095 | xha`k'0`i'==8095 replace mtrav_inter`k'_`i'=4 if xha`k'0`i'==34 | xha`k'0`i'==94 | xha`k'0`i'==134 | xha`k'0`i'==1094 | xha`k'0`i'==2094 | xha`k'0`i'==3094 | xha`k'0`i'==4094 | xha`k'0`i'==5094 | xha`k'0`i'==6094 | xha`k'0`i'==7094 | xha`k'0`i'==8094 | xha`k'0`i'==194 | xha`k'0`i'==1194 | xha`k'0`i'==2194 | xha`k'0`i'==3194 | xha`k'0`i'==4194 | xha`k'0`i'==5194 | xha`k'0`i'==6194 | xha`k'0`i'==7194 | xha`k'0`i'==8194 replace mtrav_inter`k'_`i'=-7 if mtrav_inter`k'_`i'==. local i=`i'+1 } local i=10 while `i'<97{ generate mtrav_inter`k'_`i'=-8 if xha`k'`i'==9999 replace mtrav_inter`k'_`i'=1 if xha`k'`i'==31 | xha`k'`i'==32 | xha`k'`i'==33 | xha`k'`i'==91 | xha`k'`i'==92 | xha`k'`i'==93 | xha`k'`i'==131 | xha`k'`i'==191 | xha`k'`i'==1091 | xha`k'`i'==1092 | xha`k'`i'==1093 | xha`k'`i'==1191 | xha`k'`i'==2091 | xha`k'`i'==2092 | xha`k'`i'==2093 | xha`k'`i'==2191 | xha`k'`i'==3091 | xha`k'`i'==3092 | xha`k'`i'==3093 | xha`k'`i'==3191 | xha`k'`i'==4091 | xha`k'`i'==4092 | xha`k'`i'==4093 | xha`k'`i'==4191 | xha`k'`i'==5091 | xha`k'`i'==5092 | xha`k'`i'==5093 | xha`k'`i'==5191 | xha`k'`i'==6091 | xha`k'`i'==6092 | xha`k'`i'==6093 | xha`k'`i'==6191 | xha`k'`i'==7091 | xha`k'`i'==7092 | xha`k'`i'==7093 | xha`k'`i'==7191 | xha`k'`i'==8091 | xha`k'`i'==8092 | xha`k'`i'==8093 | xha`k'`i'==8191 replace mtrav_inter`k'_`i'=2 if xha`k'`i'==36 | xha`k'`i'==96 | xha`k'`i'==1096 | xha`k'`i'==2096 | xha`k'`i'==3096 | xha`k'`i'==4096 | xha`k'`i'==5096 | xha`k'`i'==6096 | xha`k'`i'==7096 | xha`k'`i'==8096 replace mtrav_inter`k'_`i'=3 if xha`k'`i'==35 | xha`k'`i'==95 | xha`k'`i'==1095 | xha`k'`i'==2095 | xha`k'`i'==3095 | xha`k'`i'==4095 | xha`k'`i'==5095 | xha`k'`i'==6095 | xha`k'`i'==7095 | xha`k'`i'==8095 replace mtrav_inter`k'_`i'=4 if xha`k'`i'==34 | xha`k'`i'==94 | xha`k'`i'==134 | xha`k'`i'==1094 | xha`k'`i'==2094 | xha`k'`i'==3094 | xha`k'`i'==4094 | xha`k'`i'==5094 | xha`k'`i'==6094 | xha`k'`i'==7094 | xha`k'`i'==8094 | xha`k'`i'==194 | xha`k'`i'==1194 | xha`k'`i'==2194 | xha`k'`i'==3194 | xha`k'`i'==4194 | xha`k'`i'==5194 | xha`k'`i'==6194 | xha`k'`i'==7194 | xha`k'`i'==8194 replace mtrav_inter`k'_`i'=-7 if mtrav_inter`k'_`i'==. local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ generate mtrav`k'_1=mtrav_inter`k'_1 local i=2 while `i'<=number_max_episodes{ generate mtrav`k'_`i'=. local l=`i'-1 local j=2 while `j'<97{ replace mtrav`k'_`i'=mtrav_inter`k'_`j' if number_episode`k'_`j'==`i' & mtrav`k'_`i'==. & mtrav`k'_`l'!=. local j=`j'+1 } local i=`i'+1 } local k=`k'+1 } drop mtrav_inter* **INFORMATION COMMUNICATION TECHNOLOGY *************************************** local k=1 while `k'<8{ local i=1 while `i'<=number_max_episodes{ generate ict`k'_`i'=-9 local i=`i'+1 } local k=`k'+1 } **LOCATION VARIABLES ******************** local k=1 while `k'<8{ local i=1 while `i'<10{ generate eloc_inter`k'_`i'=1 if pl`k'0`i'==1 replace eloc_inter`k'_`i'=9 if xha`k'0`i'==7000 | xha`k'0`i'==7010 | xha`k'0`i'==7011 | xha`k'0`i'==7020 | xha`k'0`i'==7030 | xha`k'0`i'==7080 | xha`k'0`i'==7081 | xha`k'0`i'==8000 | xha`k'0`i'==8010 | xha`k'0`i'==8020 | xha`k'0`i'==8030 replace eloc_inter`k'_`i'=8 if (xha`k'0`i'>=31 & xha`k'0`i'<=36) | (xha`k'0`i'>=91 & xha`k'0`i'<=96) | (xha`k'0`i'>=1091 & xha`k'0`i'<=1096) | (xha`k'0`i'>=2091 & xha`k'0`i'<=2096) | (xha`k'0`i'>=3091 & xha`k'0`i'<=3096) | (xha`k'0`i'>=4091 & xha`k'0`i'<=4096) | (xha`k'0`i'>=5091 & xha`k'0`i'<=5096) | (xha`k'0`i'>=6091 & xha`k'0`i'<=6096) | (xha`k'0`i'>=7091 & xha`k'0`i'<=7096) | (xha`k'0`i'>=8091 & xha`k'0`i'<=8096) | xha`k'0`i'==131 | xha`k'0`i'==134 | xha`k'0`i'==191 | xha`k'0`i'==194 | xha`k'0`i'==1191 | xha`k'0`i'==1194 | xha`k'0`i'==2191 | xha`k'0`i'==2194 | xha`k'0`i'==3191 | xha`k'0`i'==3194 | xha`k'0`i'==4191 | xha`k'0`i'==4194 | xha`k'0`i'==5191 | xha`k'0`i'==5194 | xha`k'0`i'==6191 | xha`k'0`i'==6194 | xha`k'0`i'==7191 | xha`k'0`i'==7194 | xha`k'0`i'==8020 | xha`k'0`i'==8191 | xha`k'0`i'==8194 | xha`k'0`i'==3140 replace eloc_inter`k'_`i'=3 if xha`k'0`i'==0 | xha`k'0`i'==20 | xha`k'0`i'==40 | xha`k'0`i'==50 | xha`k'0`i'==55 | xha`k'0`i'==60 | xha`k'0`i'==70 | xha`k'0`i'==80 replace eloc_inter`k'_`i'=6 if xha`k'0`i'==4040 | xha`k'0`i'==7070 replace eloc_inter`k'_`i'=5 if (xha`k'0`i'>=3000 & xha`k'0`i'<=3070) | xha`k'0`i'==3140 | xha`k'0`i'==5080 replace eloc_inter`k'_`i'=4 if (xha`k'0`i'==5000) | ((xha`k'0`i'>=5001 & xha`k'0`i'<=5060) & pl`k'0`i'!=1) | ((xha`k'0`i'>=5070 & xha`k'0`i'<=5075) & pl`k'0`i'!=1) replace eloc_inter`k'_`i'=7 if (xha`k'0`i'==6040 | xha`k'0`i'==6050) & (pl`k'0`i'==2 | pl`k'0`i'==3) replace eloc_inter`k'_`i'=2 if xha`k'0`i'==7050 replace eloc_inter`k'_`i'=-8 if eloc_inter`k'_`i'==. local i=`i'+1 } local i=10 while `i'<97{ generate eloc_inter`k'_`i'=1 if pl`k'`i'==1 replace eloc_inter`k'_`i'=9 if xha`k'`i'==7000 | xha`k'`i'==7010 | xha`k'`i'==7011 | xha`k'`i'==7020 | xha`k'`i'==7030 | xha`k'`i'==7080 | xha`k'`i'==7081 | xha`k'`i'==8000 | xha`k'`i'==8010 | xha`k'`i'==8020 | xha`k'`i'==8030 replace eloc_inter`k'_`i'=8 if (xha`k'`i'>=31 & xha`k'`i'<=36) | (xha`k'`i'>=91 & xha`k'`i'<=96) | (xha`k'`i'>=1091 & xha`k'`i'<=1096) | (xha`k'`i'>=2091 & xha`k'`i'<=2096) | (xha`k'`i'>=3091 & xha`k'`i'<=3096) | (xha`k'`i'>=4091 & xha`k'`i'<=4096) | (xha`k'`i'>=5091 & xha`k'`i'<=5096) | (xha`k'`i'>=6091 & xha`k'`i'<=6096) | (xha`k'`i'>=7091 & xha`k'`i'<=7096) | (xha`k'`i'>=8091 & xha`k'`i'<=8096) | xha`k'`i'==131 | xha`k'`i'==134 | xha`k'`i'==191 | xha`k'`i'==194 | xha`k'`i'==1191 | xha`k'`i'==1194 | xha`k'`i'==2191 | xha`k'`i'==2194 | xha`k'`i'==3191 | xha`k'`i'==3194 | xha`k'`i'==4191 | xha`k'`i'==4194 | xha`k'`i'==5191 | xha`k'`i'==5194 | xha`k'`i'==6191 | xha`k'`i'==6194 | xha`k'`i'==7191 | xha`k'`i'==7194 | xha`k'`i'==8020 | xha`k'`i'==8191 | xha`k'`i'==8194 | xha`k'`i'==3140 replace eloc_inter`k'_`i'=3 if xha`k'`i'==0 | xha`k'`i'==20 | xha`k'`i'==40 | xha`k'`i'==50 | xha`k'`i'==55 | xha`k'`i'==60 | xha`k'`i'==70 | xha`k'`i'==80 replace eloc_inter`k'_`i'=6 if xha`k'`i'==4040 | xha`k'`i'==7070 replace eloc_inter`k'_`i'=5 if (xha`k'`i'>=3000 & xha`k'`i'<=3070) | xha`k'`i'==3140 | xha`k'`i'==5080 replace eloc_inter`k'_`i'=4 if (xha`k'`i'==5000) | ((xha`k'`i'>=5001 & xha`k'`i'<=5060) & pl`k'`i'!=1) | ((xha`k'`i'>=5070 & xha`k'`i'<=5075) & pl`k'`i'!=1) replace eloc_inter`k'_`i'=7 if (xha`k'`i'==6040 | xha`k'`i'==6050) & (pl`k'`i'==2 | pl`k'`i'==3) replace eloc_inter`k'_`i'=2 if xha`k'`i'==7050 replace eloc_inter`k'_`i'=-8 if eloc_inter`k'_`i'==. local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=1 while `i'<96{ local j=`i'+1 replace eloc_inter`k'_`i'=eloc_inter`k'_`j' if eloc_inter`k'_`i'==-8 & eloc_inter`k'_`j'!=8 & eloc_inter`k'_`j'!=-8 local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ local i=2 while `i'<96{ local j=`i'-1 replace eloc_inter`k'_`i'=eloc_inter`k'_`j' if eloc_inter`k'_`i'==-8 & eloc_inter`k'_`j'!=8 & eloc_inter`k'_`j'!=-8 local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ generate eloc`k'_1=eloc_inter`k'_1 local i=2 while `i'<=number_max_episodes{ generate eloc`k'_`i'=. local l=`i'-1 local j=2 while `j'<97{ replace eloc`k'_`i'=eloc_inter`k'_`j' if number_episode`k'_`j'==`i' & eloc`k'_`i'==. & eloc`k'_`l'!=. local j=`j'+1 } local i=`i'+1 } local k=`k'+1 } drop eloc_inter* **IN AND OUT VARIABLE ********************** local k=1 while `k'<8{ local i=1 while `i'<10{ generate inout_inter`k'_`i'=3 if ((xha`k'0`i'>=31 & xha`k'0`i'<=37) | (xha`k'0`i'>=91 & xha`k'0`i'<=97) | (xha`k'0`i'>=1091 & xha`k'0`i'<=1097) | (xha`k'0`i'>=2091 & xha`k'0`i'<=2097) | (xha`k'0`i'>=3091 & xha`k'0`i'<=3097) | (xha`k'0`i'>=4091 & xha`k'0`i'<=4097) | (xha`k'0`i'>=5091 & xha`k'0`i'<=5097) | (xha`k'0`i'>=6091 & xha`k'0`i'<=6097) | (xha`k'0`i'>=7091 & xha`k'0`i'<=7097) | (xha`k'0`i'>=8091 & xha`k'0`i'<=8097)) & (xha`k'0`i'!=35 & xha`k'0`i'!=95 & xha`k'0`i'!=1095 & xha`k'0`i'!=2095 & xha`k'0`i'!=3095 & xha`k'0`i'!=4095 & xha`k'0`i'!=5095 & xha`k'0`i'!=6095 & xha`k'0`i'!=7095 & xha`k'0`i'!=8095) & (xha`k'0`i'!=34 & xha`k'0`i'!=94 & xha`k'0`i'!=1094 & xha`k'0`i'!=2094 & xha`k'0`i'!=3094 & xha`k'0`i'!=4094 & xha`k'0`i'!=5094 & xha`k'0`i'!=6094 & xha`k'0`i'!=7094 & xha`k'0`i'!=8094) replace inout_inter`k'_`i'=3 if xha`k'0`i'==131 | xha`k'0`i'==191 | xha`k'0`i'==1191 | xha`k'0`i'==2191 | xha`k'0`i'==3191 | xha`k'0`i'==4191 | xha`k'0`i'==5191 | xha`k'0`i'==6191 | xha`k'0`i'==7191 | xha`k'0`i'==8191 replace inout_inter`k'_`i'=2 if (xha`k'0`i'>=1030 & xha`k'0`i'<=1032) | xha`k'0`i'==1051 | xha`k'0`i'==1072 | xha`k'0`i'==2050 | (xha`k'0`i'>8000 & xha`k'0`i'<=8030) | xha`k'0`i'==35 | xha`k'0`i'==95 | xha`k'0`i'==1095 | xha`k'0`i'==2095 | xha`k'0`i'==3095 | xha`k'0`i'==4095 | xha`k'0`i'==5095 | xha`k'0`i'==6095 | xha`k'0`i'==7095 | xha`k'0`i'==8095 | xha`k'0`i'==8081 | xha`k'0`i'==134 | xha`k'0`i'==194 | xha`k'0`i'==1194 | xha`k'0`i'==2194 | xha`k'0`i'==3194 | xha`k'0`i'==4194 | xha`k'0`i'==5194 | xha`k'0`i'==6194 | xha`k'0`i'==7194 | xha`k'0`i'==8194 replace inout_inter`k'_`i'=2 if xha`k'0`i'==34 | xha`k'0`i'==94 | xha`k'0`i'==1094 | xha`k'0`i'==2094 | xha`k'0`i'==3094 | xha`k'0`i'==4094 | xha`k'0`i'==5094 | xha`k'0`i'==6094 | xha`k'0`i'==7094 | xha`k'0`i'==8094 replace inout_inter`k'_`i'=1 if (xha`k'0`i'>=1000 & xha`k'0`i'<=1025) | (xha`k'0`i'>=1041 & xha`k'0`i'<=1042) | xha`k'0`i'==1110 | xha`k'0`i'==2040 | xha`k'0`i'==4000 | xha`k'0`i'==4001 | xha`k'0`i'==4030 | xha`k'0`i'==4010 | (xha`k'0`i'>=4050 & xha`k'0`i'<=4080) | (xha`k'0`i'>=7050 & xha`k'0`i'<=7070) | (xha`k'0`i'>=8040 & xha`k'0`i'<=8073) | xha`k'0`i'==8082 | (xha`k'0`i'>=9101 & xha`k'0`i'<=9152) | xha`k'0`i'==3001 | xha`k'0`i'==3002 | xha`k'0`i'==3010 | xha`k'0`i'==3011 | xha`k'0`i'==3012 | xha`k'0`i'==3013 | xha`k'0`i'==3014 | xha`k'0`i'==3015 | xha`k'0`i'==4040 | xha`k'0`i'==5080 | xha`k'0`i'==2000 | xha`k'0`i'==2010 replace inout_inter`k'_`i'=-8 if inout_inter`k'_`i'==. local i=`i'+1 } local i=10 while `i'<97{ generate inout_inter`k'_`i'=3 if ((xha`k'`i'>=31 & xha`k'`i'<=37) | (xha`k'`i'>=91 & xha`k'`i'<=97) | (xha`k'`i'>=1091 & xha`k'`i'<=1097) | (xha`k'`i'>=2091 & xha`k'`i'<=2097) | (xha`k'`i'>=3091 & xha`k'`i'<=3097) | (xha`k'`i'>=4091 & xha`k'`i'<=4097) | (xha`k'`i'>=5091 & xha`k'`i'<=5097) | (xha`k'`i'>=6091 & xha`k'`i'<=6097) | (xha`k'`i'>=7091 & xha`k'`i'<=7097) | (xha`k'`i'>=8091 & xha`k'`i'<=8097)) & (xha`k'`i'!=35 & xha`k'`i'!=95 & xha`k'`i'!=1095 & xha`k'`i'!=2095 & xha`k'`i'!=3095 & xha`k'`i'!=4095 & xha`k'`i'!=5095 & xha`k'`i'!=6095 & xha`k'`i'!=7095 & xha`k'`i'!=8095) & (xha`k'`i'!=34 & xha`k'`i'!=94 & xha`k'`i'!=1094 & xha`k'`i'!=2094 & xha`k'`i'!=3094 & xha`k'`i'!=4094 & xha`k'`i'!=5094 & xha`k'`i'!=6094 & xha`k'`i'!=7094 & xha`k'`i'!=8094) replace inout_inter`k'_`i'=3 if xha`k'`i'==131 | xha`k'`i'==191 | xha`k'`i'==1191 | xha`k'`i'==2191 | xha`k'`i'==3191 | xha`k'`i'==4191 | xha`k'`i'==5191 | xha`k'`i'==6191 | xha`k'`i'==7191 | xha`k'`i'==8191 replace inout_inter`k'_`i'=2 if (xha`k'`i'>=1030 & xha`k'`i'<=1032) | xha`k'`i'==1051 | xha`k'`i'==1072 | xha`k'`i'==2050 | (xha`k'`i'>8000 & xha`k'`i'<=8030) | xha`k'`i'==35 | xha`k'`i'==95 | xha`k'`i'==1095 | xha`k'`i'==2095 | xha`k'`i'==3095 | xha`k'`i'==4095 | xha`k'`i'==5095 | xha`k'`i'==6095 | xha`k'`i'==7095 | xha`k'`i'==8095 | xha`k'`i'==8081 | xha`k'`i'==134 | xha`k'`i'==194 | xha`k'`i'==1194 | xha`k'`i'==2194 | xha`k'`i'==3194 | xha`k'`i'==4194 | xha`k'`i'==5194 | xha`k'`i'==6194 | xha`k'`i'==7194 | xha`k'`i'==8194 replace inout_inter`k'_`i'=2 if xha`k'`i'==34 | xha`k'`i'==94 | xha`k'`i'==1094 | xha`k'`i'==2094 | xha`k'`i'==3094 | xha`k'`i'==4094 | xha`k'`i'==5094 | xha`k'`i'==6094 | xha`k'`i'==7094 | xha`k'`i'==8094 replace inout_inter`k'_`i'=1 if (xha`k'`i'>=1000 & xha`k'`i'<=1025) | (xha`k'`i'>=1041 & xha`k'`i'<=1042) | xha`k'`i'==1110 | xha`k'`i'==2040 | xha`k'`i'==4000 | xha`k'`i'==4001 | xha`k'`i'==4030 | xha`k'`i'==4010 | (xha`k'`i'>=4050 & xha`k'`i'<=4080) | (xha`k'`i'>=7050 & xha`k'`i'<=7070) | (xha`k'`i'>=8040 & xha`k'`i'<=8073) | xha`k'`i'==8082 | (xha`k'`i'>=9101 & xha`k'`i'<=9152) | xha`k'`i'==3001 | xha`k'`i'==3002 | xha`k'`i'==3010 | xha`k'`i'==3011 | xha`k'`i'==3012 | xha`k'`i'==3013 | xha`k'`i'==3014 | xha`k'`i'==3015 | xha`k'`i'==4040 | xha`k'`i'==5080 | xha`k'`i'==2000 | xha`k'`i'==2010 replace inout_inter`k'_`i'=-8 if inout_inter`k'_`i'==. local i=`i'+1 } local k=`k'+1 } local k=1 while `k'<8{ generate inout`k'_1=inout_inter`k'_1 local i=2 while `i'<=number_max_episodes{ generate inout`k'_`i'=. local l=`i'-1 local j=2 while `j'<97{ replace inout`k'_`i'=inout_inter`k'_`j' if number_episode`k'_`j'==`i' & inout`k'_`i'==. & inout`k'_`l'!=. local j=`j'+1 } local i=`i'+1 } local k=`k'+1 } drop inout_inter* save Intermedio_W6.dta, replace ********************************************************** use Intermedio_W6.dta, clear expand 7 sort respnr generate day=. replace day=1 if _n==1 local j=1 while `j'<=_N{ local i=`j'-1 replace day=day[`i']+1 if respnr[`i']==respnr[`j'] & _n==`j' replace day=1 if respnr[`i']!=respnr[`j'] & _n==`j' local i=`i'+1 local j=`j'+1 } sort respnr day local i=1 while `i'<=number_max_episodes{ generate av`i'=. for num 1/7: replace av`i'=avX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate main`i'=. for num 1/7: replace main`i'=mainX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate sec`i'=. for num 1/7: replace sec`i'=secX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate time`i'=. for num 1/7: replace time`i'=timeX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate clockst`i'=. for num 1/7: replace clockst`i'=clockstX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate start`i'=. for num 1/7: replace start`i'=startX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate end`i'=. for num 1/7: replace end`i'=endX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate mtrav`i'=. for num 1/7: replace mtrav`i'=mtravX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate ict`i'=. for num 1/7: replace ict`i'=ictX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate eloc`i'=. for num 1/7: replace eloc`i'=elocX_`i' if day==X local i=`i'+1 } local i=1 while `i'<=number_max_episodes{ generate inout`i'=. for num 1/7: replace inout`i'=inoutX_`i' if day==X local i=`i'+1 } **WE NOW CREATE THE CALENDAR DAY ******************************** local i=1 while `i'<=number_max_episodes{ generate cday`i'=. for num 1/7: replace cday`i'=X+4 if week==1 & day==X for num 1/7: replace cday`i'=X+11 if week==2 & day==X for num 1/7: replace cday`i'=X+1 if week==3 & day==X local i=`i'+1 } egen group=group(respnr day) compress keep respnr day av* main* sec* time* clockst* start* end* inout* eloc* mtrav* ict* group cday* for num 1/7: drop avX_* mainX_* secX_* timeX_* clockstX_* startX_* endX_* time_transcurredX_* mtravX_* ictX_* elocX_* inoutX_* reshape long av main sec time clockst start end mtrav ict eloc inout cday, i(group) j(epnum) drop if av==. compress generate sppart=-9 generate alone=-9 generate child=-9 generate oad=-9 **CHECKS OF "mtrav" AND "inout" ******************************* tab main if (mtrav==3 | mtrav==4) /* main | Freq. Percent Cum. ------------+----------------------------------- 11 | 264 1.89 1.89 63 | 2,467 17.66 19.55 64 | 1,648 11.80 31.35 65 | 769 5.51 36.86 66 | 1,303 9.33 46.18 67 | 4,203 30.09 76.27 68 | 3,314 23.73 100.00 ------------+----------------------------------- Total | 13,968 100.00 */ replace eloc=8 if (mtrav==1 | mtrav==2) & eloc==5 /* 393 cases, with shopping related travel */ replace inout=2 if mtrav==3 | mtrav==4 replace eloc=8 if eloc==5 & main==67 replace eloc=-8 if eloc==8 & main==42 ***INCONSISTENCIES SECONDARY ACTIVITIES (RADIO OR TV) ***************************************************** replace sec=58 if sec==59 & (mtrav>0) replace sec=58 if sec==59 & (inout==2 | inout==3) replace sec=58 if sec==59 & (eloc==4 | eloc==5 | eloc==7 | eloc==8 | eloc==9) replace sec=0 if main==58 & sec==58 replace sec=0 if main==59 & sec==59 sort respnr day ***labels ********** #delimit; lab var cday "Calendar day diary kept"; lab var time "Duration of activity in minutes"; lab var clockst "Start time on 24 hour clock"; lab var start "Start minute (of 1440 min 0=begin of diary)"; lab var end "End minute (of 1440 min 1440=end of diary)"; lab var epnum "Episode number"; lab var main "Main act, 69 category list"; lab def main 1 "imputed personal or household care" 2 "sleep and naps" 3 "imputed sleep" 4 "wash, dress, care for self" 5 "meals at work or school" 6 "other meals or snacks" 7 "paid work- job (not at home)" 8 "paid work at home" 9 "second or other job not at home" 10 "unpaid work to generate household income" 11 "travel as a part of work" 12 "work breaks" 13 "other time at workplace" 14 "look for work" 15 "regular schooling, education" 16 "homework" 17 "leisure/other education or training" 18 "food preparation, cooking" 19 "set table, wash/put away dishes" 20 "cleaning" 21 "laundry, ironing, clothing repair" 22 " tain home/vehicle" 23 "other domestic work" 24 "purchase goods" 25 "consume personal care services" 26 "consume other services" 27 "pet care (not walk dog)" 28 "physical, medical child care" 29 "teach, help with homework" 30 "read to, talk or play with child" 31 "supervise, accompany, other child care" 32 "adult care" 33 "voluntary, civic, organisational act" 34 "worship and religion" 35 "general out-of-home leisure" 36 "attend sporting event" 37 "cinema, theatre, opera, concert" 38 "other public event, venue" 39 "restaurant, café, bar, pub" 40 "party, social event, gambling" 41 "imputed time away from home" 42 "general sport or exercise" 43 "walking" 44 "cycling" 45 "other outside recreation" 46 "gardening/pick mushrooms" 47 "walk dogs" 48 "receive or visit friends" 49 "conversation (in person, phone)" 50 "other in-home social, games" 51 "general indoor leisure" 52 "art or music" 53 "correspondence (not e-lab mail)" 54 "knit, crafts or hobbies" 55 "relax, think, do nothing" 56 "read" 57 "listen to music etc" 58 "listen to radio" 59 "watch TV, video, DVD" 60 "computer games" 61 "e-lab mail, surf internet, computing" 62 "no act but recorded transport mode" 63 "travel to/from work" 64 "education travel" 65 "voluntary/civic/religious travel" 66 "child/adult care travel" 67 "shop, person/hhld care travel" 68 "other travel" 69 "no recorded activity"; lab val main main; lab var sec "Secondary act, 69 category list"; lab def sec -9 "no secondary activity in study" -7 "no second act collected from diary group" 1 "imputed personal or household care" 2 "sleep and naps" 3 "imputed sleep" 4 "wash, dress, care for self" 5 "meals at work or school" 6 "other meals or snacks" 7 "paid work-main job (not at home)" 8 "paid work at home" 9 "second or other job not at home" 10 "unpaid work to generate household income" 11 "travel as a part of work" 12 "work breaks" 13 "other time at workplace" 14 "look for work" 15 "regular schooling, education" 16 "homework" 17 "leisure/other education or training" 18 "food preparation, cooking" 19 "set table, wash/put away dishes" 20 "cleaning" 21 "laundry, ironing, clothing repair" 22 "maintain home/vehicle" 23 "other domestic work" 24 "purchase goods" 25 "consume personal care services" 26 "consume other services" 27 "pet care (not walk dog)" 28 "physical, medical child care" 29 "teach, help with homework" 30 "read to, talk or play with child" 31 "supervise, accompany, other child care" 32 "adult care" 33 "voluntary, civic, organisational act" 34 "worship and religion" 35 "general out-of-home leisure" 36 "attend sporting event" 37 "cinema, theatre, opera, concert" 38 "other public event, venue" 39 "restaurant, café, bar, pub" 40 "party, social event, gambling" 41 "imputed time away from home" 42 "general sport or exercise" 43 "walking" 44 "cycling" 45 "other outside recreation" 46 "gardening/pick mushrooms" 47 "walk dogs" 48 "receive or visit friends" 49 "conversation (in person, phone)" 50 "other in-home social, games" 51 "general indoor leisure" 52 "art or music" 53 "correspondence (not e-mail)" 54 "knit, crafts or hobbies" 55 "relax, think, do nothing" 56 "read" 57 "listen to music etc" 58 "listen to radio" 59 "watch TV, video, DVD" 60 "computer games" 61 "e-mail, surf internet, computing" 62 "no act but recorded transport mode" 63 "travel to/from work" 64 "education travel" 65 "voluntary/civic/religious travel" 66 "child/adult care travel" 67 "shop, person/hhld care travel" 68 "other travel" 69 "no recorded activity"; lab val sec sec; lab var av "Main act, old MTUS 41 category list"; lab def av 1 "paid work" 2 "paid work at home" 3 "second job" 4 "school/classes" 5 "travel to/from work" 6 "cook, wash up" 7 "housework" 8 "odd jobs" 9 "gardening" 10 "shopping" 11 "childcare" 12 "domestic travel" 13 "dress/personal care" 14 "consume services" 15 "meals, snacks" 16 "sleep" 17 "free time travel" 18 "excursions" 19 "active sport" 20 "passive sport" 21 "walks" 22 "religious activity" 23 "civic activity" 24 "cinema, theatre" 25 "dances, parties" 26 "social club" 27 "pub" 28 "restaurant" 29 "visit friends" 30 "listen to radio" 31 "TV, video" 32 "listen to CDs records" 33 "study" 34 "read books" 35 "read paper/magazine" 36 "relax" 37 "conversation" 38 "entertain friends" 39 "knit, sew" 40 "other leisure" 41 "missing"; lab val av av; lab var inout "Inside or outside"; lab def inout -9 "location not collected by study" -8 "location unknown" -7 "location not collected from diary group" 1 "inside" 2 "outside" 3 "in vehicle"; lab val inout inout; lab var eloc "Location"; lab def eloc -9 "location not collected by study" -8 "location unknown" -7 "location not collected from diary group" 1 "at own home" 2 "at another’s home" 3 "at workplace" 4 "at school" 5 "at services or shops" 6 "at restaurant, bar etc" 7 "at place of worship" 8 "travelling" 9 "other locations"; lab val eloc eloc; lab var ict "Used ict during activity"; lab def ict -9 "could not be created for study" -7 "not collected for diary group" 0 "no" 1 "yes"; lab val ict ict; lab var mtrav "Mode of transport"; lab def mtrav -9 "mode not collected by study" -8 "missing" -7 "not travelling" 1 "travel by car etc" 2 "public transport" 3 "walk / on foot" 4 "other physical transport" 5 "other/unspecified transport"; lab val mtrav mtrav; lab var alone "Time alone or with strangers"; lab def alone -9 "could not be created for study" -7 "not collected for diary group" 0 "no" 1 "yes"; lab val alone alone; lab var child "Child aged <18 present"; lab def child -9 "could not be created for study" -7 "not collected for diary group" 0 "no" 1 "yes"; lab val child child; lab var sppart "Spouse or partner present"; lab def sppart -9 "could not be created for study" -7 "not collected for diary group" 0 "no" 1 "yes"; lab val sppart sppart; lab var oad "Other adult present"; lab def oad -9 "could not be created for study" -7 "not collected for diary group" 0 "no" 1 "yes"; lab val oad oad; lab var day "Day of week diary kept"; lab def day 1 "Sunday" 2 "Monday" 3 "Tuesday" 4 "Wednesday" 5 "Thursday" 6 "Friday" 7 "Saturday" 8 "Whole week average" 9 "Unspecified weekday" 10 "Unspecified weekend day" -8 "missing" -9 "could not be created"; lab val day day; #delimit cr save Intermedio_W6.dta, replace use Net1980W_inter.dta, clear keep countrya survey swave msamp hldid persid id day month year diary badcase sex age ocombwt propwt respnr sort respnr day save Merge_W6.dta, replace use Intermedio_W6.dta,clear merge respnr day using Merge_W6.dta keep countrya survey swave msamp hldid persid id day month year diary badcase sex age time clockst start end epnum main sec av inout eloc ict mtrav alone child sppart oad ocombwt propwt cday order countrya survey swave msamp hldid persid id day cday month year diary badcase sex age time clockst start end epnum main sec av inout eloc ict mtrav alone child sppart oad ocombwt propwt saveold Intermedio_W6.dta, replace **************************************************************************************************************************************************************************** **************************************************************************************************************************************************************************** ******************************************************************* WE NOW SAVE ALL THE DATASETS *************************************************************************** **************************************************************************************************************************************************************************** **************************************************************************************************************************************************************************** clear **W553 ******* use Net1980W_inter.dta, clear keep countrya survey swave msamp hldid persid id parntid1 parntid2 partid day month year diary badcase hhtype hhldsize nchild agekidx agekid2 incorig income ownhome urban computer vehicle sex age famstat cphome singpar relrefp civstat cohab citizen empstat emp unemp student retired empsp workhrs empinclm occup sector educa edtry rushed health carer disab av* ocombwt propwt sort swave msamp hldid persid id saveold Net1980W553.dta, replace **W58 ***** use Net1980W_inter.dta, clear drop respnr drop if age<18 sort swave msamp hldid persid id saveold Net1980W58.dta, replace **W58KID ******** use Net1980W_inter.dta, clear drop respnr drop if age>=18 sort swave msamp hldid persid id saveold Net1980W58kid.dta, replace **W6 **** use Intermedio_W6.dta, clear drop if age<18 drop ocombwt propwt sort swave msamp hldid persid id epnum saveold Net1980W6.dta, replace **W6KID ******* use Intermedio_W6.dta, clear drop if age>=18 drop ocombwt propwt sort swave msamp hldid persid id epnum saveold Net1980W6kid.dta, replace ******************************* clear erase Net1980W_inter.dta erase Intermedio_W6.dta erase Merge_W6.dta