******************************************************** * MAI ANH TUAN PhD5 ID:567110018-8 * * Achievement of Treatment Goals (ABC) during 3 years * ******************************************************** *-------------------------------------------------* clear set more off cd "D:\My Documents\Google Drive\AAAPHD5\18 jun\EDA - DMHT_2553_54_55\" use "10_DMHT2553_54_55_Data_Final_20130522.dta", clear *====================== Step 1: Prepare outcome ABC (ADA taget)===* *= a1c <7% *= ldl < 110 *== sbp Systolic <130 mm Hg *== dbp Diastolic <85 mm Hg *= combine bp_gr : 1. sbp <130 or dbp<85; 2. both (<130/85) *= combine ABC: * HbA1c(<7%) and LDL-C (<100 mg/dL) * HbA1c(<7%) and bp(<130/85 mm Hg) * HbA1c(<7%) and bp(<130/85 mm Hg) and dm_ldl (<100 mg/dL) *====================================== drop if dm_ht==2 /*95035 observations deleted*/ drop ht_* /* drop all var of Hypertension*/ recode dm_hba1c (-9 = .) /* ? range ?*/ recode dm_hba1c (-73 = .) recode dm_ldl (-9 = .) recode dm_ldl (1000/2000 = .) recode sbp (-9 = .) recode dbp (-9 = .) save "D:\My Documents\Google Drive\AAAPHD5\18 jun\EDA - DMHT_2553_54_55\ABC3year.dta",replace * GEN ABC: 4 step * 1. a1cgr : gen a1c 2 group gen a1cgr=. /* 1=<7 0=>=7 */ replace a1cgr=1 if dm_hba1c <7 & dm_hba1c !=. replace a1cgr=0 if dm_hba1c >=7 & dm_hba1c <. lab var a1cgr "a1c 2 group" tab a1cgr, mis * 2. ldlgr : gen ldl 2 group gen ldlgr=. /* 1=<110 0=>=110 */ replace ldlgr=1 if dm_ldl <110 & dm_ldl !=. replace ldlgr=0 if dm_ldl >=110 & dm_ldl <. lab var ldlgr "ldl 2 group" tab ldl, mis * 3. bp2gr: gen BP 2 group gen testbp=sbp-dbp /*clear data*/ gen bpcl=. replace bpcl=1 if testbp>20 & testbp <. replace bpcl=2 if testbp<=20 & testbp <. tab bpcl sum sbp dbp replace sbp =. if bpcl==2 replace dbp =. if bpcl==2 sum sbp dbp count if sbp !=. & dbp==. /* dbp or sbp missing on 1 record*/ count if sbp ==. & dbp!=. replace sbp =. if sbp!=. & dbp==. replace dbp =. if sbp==. & dbp!=. gen bp3gr=. /* 2. sbp<130&dbp<85; 1. >+130<85 or <130>=85; 0. else*/ replace bp3gr=2 if sbp<130 & dbp<85 replace bp3gr=0 if sbp>=130 & dbp>=85 & dbp<. replace bp3gr=1 if sbp<130 & dbp>=85 & dbp<. replace bp3gr=1 if sbp>=130 & dbp<85 & dbp<. lab var bp3gr "bpgr 3 group" gen bp2gr=. /* 1. sbp<130&dbp<85; 0. other */ replace bp2gr=0 if bp3gr<2 replace bp2gr=1 if bp3gr==2 /* */ lab var bp2gr "bpgr 2 group" tab1 bp3gr bp2gr, mis /* 4. gen ABC a1cgr(<7%) and ldlgr (<100 mg/dL) a1cgr(<7%) and bp2gr (<130/85 mm Hg) a1cgr(<7%) and bp2gr (<130/85 mm Hg) and ldl (<100 mg/dL)*/ tab1 a1cgr ldlgr bp2gr, mis /*test*/ gen totalabc=a1cgr+bp2gr+ldlgr tab totalabc, mis /**/ gen abc6gr=. replace abc6gr=5 if a1cgr==1&ldlgr==1&bp2gr==1&totalabc==3/*both3*/ replace abc6gr=4 if a1cgr==1&bp2gr==1&totalabc==2 /*a1c+bp*/ replace abc6gr=3 if a1cgr==1&ldlgr==1&totalabc==2 /*a1c+ldl*/ replace abc6gr=2 if ldlgr==1&bp2gr==1&totalabc==2 replace abc6gr=1 if (totalabc==1&a1cgr==1)|(totalabc==1&ldlgr==1)|(bp2gr==1&totalabc==1) replace abc6gr=0 if a1cgr==0&ldlgr==0&bp2gr==0 tab abc6gr totalabc, mis *====================== Prepare covariate ===* * sex, age, dm_ht, treat (2 year), dmdura(2 year) destring dmdate, gen(dmdate1) recode dmdate1 (-9 =.) recode dmdate1 (2556/2566=.) gen dmdura=year-dmdate1 /*the duration time get dm */ sum dmdura,d /*non-standard distribution*/ *======================================= tables 1==================* *======================================= tables 2==================* *======================================= tables 3==================* drop abc6gr replace abc6gr=1 if (abc==.&a1cgr==1)|(abc==.&ldlgr==1)|(abc==.&bp2gr==1) qnorm dm_ldl pnorm dm_ldl sktest dm_ldl // sum dm_ldl dm_hba1c, d hist dm_ldl, norm help sum *================================ *======================== Factor of interest ==> dm_ht tab dm_ht, nolab mis drop if dm_ht==2 //(95035 observations deleted) drop ht_* // drop all var of Hypertension *Covariate ==> sex, age, dm_dura label variable type "financy" //1. Test distribution, variance sum dm_hdl,d sum dm_hba1c,d graph box dm_hba1c, over(year) over(sex) *** A1c sex#year oneway dm_hba1c year,t table sex year, cont(freq mean age) mis anova dm_hba1c year sex sex#year anovaplot, scatter(ms(i)) graph box dm_hba1c, over(year) over(sex) *** A1c dm_ht#year *graph box dm_hba1c, over(year) over(dm_ht) table dm_ht year, cont(mean dm_hba1c) anova dm_hba1c year dm_ht dm_ht#year regress anovaplot, scatter(ms(i)) table dm_ht year, freq mean dm_hba1c) ???anova dm_hba1c year sex sex#year, sequential *=================================== // exxample anova// use http://www.ats.ucla.edu/stat/stata/examples/kirk/crf33, clear tabdisp order b a, cellvar(y) table a b, cont(sum y) table a b, cont(mean y) anova y b a b#a anovaplot scatter(msymbol(i)) quietly anova y a b a#b anovaplot, scatter(msymbol(i)) sme a b sme b a