capture log close _all clear * Define some variables; local today=subinstr("`c(current_date)'"," ","",.) local time=subinstr("`c(current_time)'",":","",.) * stata version compatibility version 16.0 * log file number local vnum="1_00" * Syntax name local syntax "Analyses01e" * Projectname local project "C19a" * Open log file; log using "$logfilepath/StataLog_AW_`project'_`syntax'_`vnum'_`today'_`time'", replace text name(Merge`syntax') local logname=r(name) timer clear 1 * Change Log ******************************** * clear use "$datafilepath/AW_`project'_Prepare01" cd "$outputpath" stsplit splitearly, after at(0) (time=mdy(4,9,2020)) replace splitearly=1 if splitearly==0 replace splitearly=0 if splitearly==-1 * Replace event variable with only the deaths we care about gen codhold=. replace codhold=0 if _d==0 replace codhold=1 if _d==1 replace _d=0 if cod_cov!=1 & _d==1 stcox b2.sex b1.marital_status b3.sun3 b3.dispink2018_3 i.mena stolan if splitearly==0 eststo mainearly, title("Main Models, Early, 6-controls") stcox b2.sex b1.marital_status b3.sun3 b3.dispink2018_3 i.mena stolan if splitearly==1 eststo mainlate, title("Main Models, Late, 6-controls") stcox b2.sex b1.marital_status b3.sun3 b3.dispink2018_3 i.mena if stolan==0 eststo mainrestcountry, title("Main Models, Rest, 6-controls") stcox b2.sex b1.marital_status b3.sun3 b3.dispink2018_3 i.mena if stolan==1 eststo mainstockholm, title("Main Models, Stockholm, 6-controls") esttab mainearly mainlate mainstockholm mainrestcountry using "$outputpath/mainrobust_`project'_`today'_`time'.rtf", mtitles b(3) ci eform nogaps scalars(N_fail risk) compress replace label * Drop first episodes for those who celebrated birthday drop if logistReg==0 * Main effect logit models logit _d b10.agecatlogist b2.sex b1.marital_status b3.sun3 b3.dispink2018_3 i.mena stolan, or eststo mainlog6, title("Main Models, Both Sexes, 6-controls") logit _d b10.agecatlogist b1.marital_status b3.sun3 b3.dispink2018_3 i.mena stolan if sex==1, or eststo mainmenlog6, title("Main Models, Men, 6-controls") logit _d b10.agecatlogist b1.marital_status b3.sun3 b3.dispink2018_3 i.mena stolan if sex==2, or eststo mainwomenlog6, title("Main Models, Women, 6-controls") esttab mainlog6 mainmenlog6 mainwomenlog6 using "$outputpath/main6log_mena_`project'_`today'_`time'.rtf", mtitles b(3) ci eform nogaps scalars(N_fail risk) compress replace label timer list 1 log close `logname'