use "accupunture_lecture7.dta", clear **Lecture 7: Table and Figures **************************************************************************** **Table 1 *Method 1: tabstat tabstat age sex migraine chronicity, by(group) stat(n mean sd) *Method 2: Using seperate tabulate commands tab group bysort group: sum age tab sex group, col tab migraine group, col bysort group: sum chronicity *Method 3: Using the tabout package (more on course website: “Making publication quality tables in stata”) ssc install tabout tabout group /// using table1.txt, replace /// c(mean age sd age N sex mean sex n migraine mean migraine mean chronicity sd chronicity) sum /// layout(col) h3(nil) /// style(tex) bt font(bold) cl1(2-5) **************************************************************************** *Figure 1 twoway /// scatter posths acuptreatments if migraine==0 /// , msize(small) mcolor(orange) || /// lfit posths acuptreatments if migraine==0 /// , lcolor(purple) || /// scatter posths acuptreatments if migraine==1 /// , msize(small) mcolor(blue) || /// lfit posths acuptreatments if migraine==1 /// , lcolor(green) || /// , title (Figure 1) /// note (note) /// ytitle(PSH) /// xtitle(# acu) /// scheme(s2color) /// legend(order(2 "No migraine" 4 "Migraine")) /// name(figure1, replace) /// saving("figure1.gph", replace) **************************************************************************** *Figure 2 twoway /// kdensity posths if no_acu==0 /// , lcolor(black) || /// kdensity posths if no_acu==1 /// , lcolor(black) || /// , yscale(on) /// graphregion(fcolor(stone) lcolor(none)) /// legend(order(1 "1 or more acupuncture treatments" 2 "No acupuncture treatments")size(medium)) /// ytitle("Density") /// xtitle("Post-study headache score") /// title(Figure 2: Distribution of headache score) /// name(figure2, replace) /// saving("figure2.gph", replace)