cd "/Users/dave/UCSF/Projects/Teaching/PhDadmin/Seminar/" set more off use "adherencebysite.dta", clear gen score = pct3*3 + pct2*2 + pct1*1 replace score = 300 if site==99 replace score = score* -1 egen rank = rank(score) gen ss = -1*rank replace ss = 0 if site==99 label def ss /// 0 "All Sites" /// -2 "San Francisco" /// -3 "Rio de Janiero" /// -4 "Sao Paulo" /// -5 "Cape Town" /// -6 "Boston" /// -7 "Rio de Janiero" /// -8 "Chiang Mai" /// -9 "Iquitos" /// -10 "Chicago" /// -11 "Guayaquil" /// -12 "Lima" label val ss ss twoway (bar four ss, sort fcolor(red) barwidth(0.75) lcolor(black) horizontal) /// (bar three ss, sort fcolor(orange) barwidth(0.75) lcolor(black) horizontal) /// (bar two ss, sort fcolor(yellow) barwidth(0.75) lcolor(black) horizontal) /// (bar one ss, sort fcolor(green) barwidth(0.75) lcolor(black) horizontal), /// ylabel(0 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12, valuelabel angle(horizontal) tlstyle(none) labsize(small)) /// xtitle("Month 1 Engagement", size(small)) xlabel(0(10)100, labsize(small)) ytitle(" " ) /// scheme(s1color) /// legend(order( 4 "{&ge} 4 Pills" 3 "2-3 Pills" 2 "< 2 Pills" 1 "No Visit") cols(4) position(12) ring(1) /// region(lwidth(none)) size(small) symysize(*.75)) plotregion(margin(zero)) graph export "orderedbyadh.pdf", replace as(pdf)