set more off clear /*create blank data set*/ set obs 1000 //creates a blank dataset gen id=_n //creates id number /*step 1: set parameters */ *i Specify exposure gen wflpct=rnormal(50,10) *ii effect modifier gen rsupplement=rnormal() gen supplement=0 replace supplement=1 if wflpct<30 & rsupplement>-1 replace supplement=1 if wflpct>=30 & wflpct<85 & rsupplement>1.5 *iii Outcome prevalence of FEV1pp <50 at 18 years gen prevFEV1pp_bad=0.75 if wflpct<50 & supplement==0 /* unsupplemented small kids risk of poor lung function */ replace prevFEV1pp_bad=0.5 if wflpct<50 & supplement==1 /* supplemented small kids risk of poor lung function*/ replace prevFEV1pp_bad=0.1 if wflpct>=50 & supplement==0 /*unsupplemented large kids risk of poor lung functin */ replace prevFEV1pp_bad=0.05 if wflpct>=50 & supplement==1 /*supplemented large kids risk for poor lung function */ gen wflsupp=0 replace wflsupp=1 if wflpct<50 & supplement==1 replace wflsupp=2 if wflpct>=50 & supplement==0 replace wflsupp=3 if wflpct>=50 & supplement==1 tabstat id, by (wflsupp) s(p75 p50 p10 p5) gen FEV1pp_bad=0 replace FEV1pp_bad=1 if id<745 & wflsupp==0 replace FEV1pp_bad=1 if id<556 & wflsupp==1 replace FEV1pp_bad=1 if id<94 & wflsupp==2 replace FEV1pp_bad=1 if id<89 & wflsupp==3 save "/Users/mollyrdju/Box Sync/MASTERS/Spring 2016/Methods in Chronic Disease Epi/week 10/HW data.dta", replace set more off clear /*create blank data set*/ set obs 1000 //creates a blank dataset gen id=_n //creates id number /*step 1: set parameters */ *i Specify exposure gen wflpct=rnormal(50,10) *ii effect modifier gen rsupplement=rnormal() gen supplement=0 replace supplement=1 if wflpct<30 & rsupplement>-1 replace supplement=1 if wflpct>=30 & wflpct<85 & rsupplement>1.5 *iii Outcome prevalence of FEV1pp <50 at 18 years gen prevFEV1pp_bad=0.1 if wflpct<50 & supplement==0 /* unsupplemented small kids risk of poor lung function */ replace prevFEV1pp_bad=0.05 if wflpct<50 & supplement==1 /* supplemented small kids risk of poor lung function*/ replace prevFEV1pp_bad=0.1 if wflpct>=50 & supplement==0 /*unsupplemented large kids risk of poor lung functin */ replace prevFEV1pp_bad=0.05 if wflpct>=50 & supplement==1 /*supplemented large kids risk for poor lung function */ gen wflsupp=0 replace wflsupp=1 if wflpct<50 & supplement==1 replace wflsupp=2 if wflpct>=50 & supplement==0 replace wflsupp=3 if wflpct>=50 & supplement==1 tabstat id, by (wflsupp) s(p75 p50 p10 p5) gen FEV1pp_bad=0 replace FEV1pp_bad=1 if id<107 & wflsupp==0 replace FEV1pp_bad=1 if id<61 & wflsupp==1 replace FEV1pp_bad=1 if id<94 & wflsupp==2 replace FEV1pp_bad=1 if id<47 & wflsupp==3 save "/Users/mollyrdju/Box Sync/MASTERS/Spring 2016/Methods in Chronic Disease Epi/week 10/HW data2.dta", replace