******************************************************************************** * Title: Can we find the missing men in clinics? Clinic attendance by sex * and HIV status in rural South Africa * * Authors: S. Randera-Rees | W.C. Safari | D. Gareta | K. Herbst | K. Baisley * | A.D. Grant * * Program Name: Frequencies of primary healthcare clinic visits by HIV status, * sex and reasons for visits among resident in the AHRI * demographic surveillance area on 1st July 2017 * * Datasets used: clinic_visits_data.csv * * Date: March 24, 2021 ******************************************************************************** version 14 clear all global data "F:\AHRI\TB\Codes\submission\Code_and_Data" cd "$data" ******************************************************************************** import delimited clinic_visits_data.csv, clear ** Data preparation ** Sex encode sex, gen(_sex) label var _sex "Sex" ** HIV status encode hivstatus, gen(hivstat) recode hivstat (2=1) (1=2) (3=3), gen(_hivstatus) label drop hivstat label def hivstat 1 "HIV-positive" 2 "HIV-negative" 3 "HIV-unknown", modify label val _hivstatus hivstat label var _hivstatus "HIV status" ** Reasons for visits encode reason_visits_cat, gen(_reasoncat) label var reason_visits_cat "Reasons for vising clinic" ** Unique id's label var unique_id_indicator "Unique identification no." ** Unique visits label var unique_visit_indicator "Unique visit indicator" ******************************************************************************** * Table 1: HIV status of 67124 adults resident in the Africa Health * Research Institute demographic surveillance area1, stratified by sex ******************************************************************************** qui{ tempname table file open `table' using "Table1.xls", write replace file write `table' _n _tab "Total (%)" _tab "Females (%)" _tab "Males (%)" file write `table' _n "Total (row %)" //row totals count if _sex<. & unique_id_indicator == 1 local N = r(N) file write `table' _tab "`N'" levelsof _sex, local(elist) foreach e in `elist' { count if _sex == `e' & unique_id_indicator == 1 local n=r(N) local p: di %3.1f `n'/`N'*100 file write `table' _tab "`n' (`p')" } foreach var in _hivstatus { local varlab: variable label `var' file write `table' _n "`varlab'" levelsof `var', local(elist) foreach e in `elist' { local xlab: label(`var') `e' ** all count if `var'~=. & `var' == `e' & unique_id_indicator == 1 local n1 = r(N) count if unique_id_indicator == 1 local N1 = r(N) ** females count if `var'~=. & `var'==`e' & unique_id_indicator ==1 & _sex==1 local n2 = r(N) count if unique_id_indicator == 1 & _sex == 1 local N2 = r(N) ** males count if `var'~=. & `var'==`e' & unique_id_indicator == 1 & _sex == 2 local n3 = r(N) count if unique_id_indicator == 1 & _sex == 2 local N3 = r(N) ** calculate percentages local p1: di %3.1f `n1'/`N1'*100 local p2: di %3.1f `n2'/`N2'*100 local p3: di %3.1f `n3'/`N3'*100 file write `table' _n "`xlab'" _tab "`n1' (`p1')" _tab "`n2' (`p2')" /// _tab "`n3' (`p3')" } } } ******************************************************************************** * Table 2: Proportion of adults resident in the Africa Health Research Institute * demographic surveillance area who attended a primary healthcare clinic * between April 2017 and March 2018, stratified by sex and HIV status. ******************************************************************************** qui{ tempname table file open `table' using "Table2.xls", write replace file write `table' _n " " _tab "HIV+: n" _tab "HIV+: N" _tab "HIV+: % (CI)" /// _tab "HIV-/unknown: n" _tab "HIV-/unknown: N" _tab "HIV-/unknown: % (CI)" /// _tab "All: n" _tab "All: N" _tab "All: % (CI)" foreach var in _sex { local varlab: variable label `var' file write `table' _n "`varlab'" levelsof `var', local(elist) foreach e in `elist' { local xlab: label(`var') `e' ** Total: hiv positive count if `var'~=. & `var'==`e' & unique_id_indicator ==1 & _hivstatus==1 & unique_visit_indicator ==1 local n1=r(N) count if `var'~=. & `var'==`e' & unique_id_indicator ==1 & _hivstatus==1 local N1=r(N) ** Calculating % local p1: di %3.1f `n1'/`N1'*100 ** Calculating 95% CI local ci1l: di %3.1f (`n1'/`N1' + invnormal(0.025)*(sqrt((1/`N1')*(`n1'/`N1')*(1-(`n1'/`N1')))))*100 local ci1u: di %3.1f (`n1'/`N1' - invnormal(0.025)*(sqrt((1/`N1')*(`n1'/`N1')*(1-(`n1'/`N1')))))*100 ** Total: hiv negative/unknown count if `var'~=. & `var'==`e' & unique_id_indicator ==1 & unique_visit_indicator ==1 & /// (_hivstatus==2 | _hivstatus==3) local n2 = r(N) count if `var'~=. & `var'==`e' & unique_id_indicator ==1 & (_hivstatus==2 | _hivstatus==3) local N2=r(N) ** Calculating % local p2: di %3.1f `n2'/`N2'*100 ** Calculating 95% CI local ci2l: di %3.1f (`n2'/`N2' + invnormal(0.025)*(sqrt((1/`N2')*(`n2'/`N2')*(1-(`n2'/`N2')))))*100 local ci2u: di %3.1f (`n2'/`N2' - invnormal(0.025)*(sqrt((1/`N2')*(`n2'/`N2')*(1-(`n2'/`N2')))))*100 ** All: count if `var'~=. & `var'==`e' & unique_id_indicator ==1 & unique_visit_indicator ==1 local n3 = r(N) count if `var'~=. & `var'==`e' & unique_id_indicator ==1 local N3 = r(N) ** Calculating % local p3: di %3.1f `n3'/`N3'*100 ** Calculating 95% CI local ci3l: di %3.1f (`n3'/`N3' + invnormal(0.025)*(sqrt((1/`N3')*(`n3'/`N3')*(1-(`n3'/`N3')))))*100 local ci3u: di %3.1f (`n3'/`N3' - invnormal(0.025)*(sqrt((1/`N3')*(`n3'/`N3')*(1-(`n3'/`N3')))))*100 file write `table' _n "`xlab'" _tab "`n1'" _tab "`N1'" /// _tab "`p1' (`ci1l', `ci1u' )" _tab "`n2'" _tab "`N2'" /// _tab "`p2' (`ci2l', `ci2u')" _tab "`n3'" _tab "`N3'" /// _tab "`p3' (`ci3l', `ci3u')" } } ** Total ** HIV positive count if unique_id_indicator ==1 & unique_visit_indicator ==1 & _hivstatus==1 local n4 = r(N) count if unique_id_indicator ==1 & _hivstatus==1 local N4 = r(N) ** Calculating % local p4: di %3.1f `n4'/`N4'*100 ** Calculating 95% CI local ci4l: di %3.1f (`n4'/`N4' + invnormal(0.025)*(sqrt((1/`N4')*(`n4'/`N4')*(1-(`n4'/`N4')))))*100 local ci4u: di %3.1f (`n4'/`N4' - invnormal(0.025)*(sqrt((1/`N4')*(`n4'/`N4')*(1-(`n4'/`N4')))))*100 ** HIV negative/unknown count if unique_id_indicator ==1 & unique_visit_indicator ==1 & (_hivstatus==2 | _hivstatus==3) local n5 = r(N) count if unique_id_indicator ==1 & (_hivstatus==2 | _hivstatus==3) local N5 = r(N) ** Calculating % local p5: di %3.1f `n5'/`N5'*100 ** Calculating 95% CI local ci5l: di %3.1f (`n5'/`N5' + invnormal(0.025)*(sqrt((1/`N5')*(`n5'/`N5')*(1-(`n5'/`N5')))))*100 local ci5u: di %3.1f (`n5'/`N5' - invnormal(0.025)*(sqrt((1/`N5')*(`n5'/`N5')*(1-(`n5'/`N5')))))*100 ** All count if unique_id_indicator ==1 & unique_visit_indicator ==1 local n6 = r(N) count if unique_id_indicator ==1 local N6 = r(N) ** Calculating % local p6: di %3.1f `n6'/`N6'*100 ** Calculating 95% CI local ci6l: di %3.1f (`n6'/`N6' + invnormal(0.025)*(sqrt((1/`N6')*(`n6'/`N6')*(1-(`n6'/`N6')))))*100 local ci6u: di %3.1f (`n6'/`N6' - invnormal(0.025)*(sqrt((1/`N6')*(`n6'/`N6')*(1-(`n6'/`N6')))))*100 file write `table' _n "Total" file write `table' _tab "`n4'" _tab "`N4'" _tab "`p4' (`ci4l', `ci4u' )" /// _tab "`n5'" _tab "`N5'" _tab "`p5' (`ci5l', `ci5u' )" /// _tab "`n6'" _tab "`N6'" _tab "`p6' (`ci6l', `ci6u' )" } ******************************************************************************** * Table 3: Number and type of primary healthcare visits made by adults resident * in the Africa Health Research Institute demographic surveillance area1 during * the study year by sex (N=88109) ******************************************************************************** qui{ tempname table file open `table' using "Table3.xls", write replace file write `table' _n " " _tab "HIV care visit: n" _tab "HIV care visit: %" /// _tab "Acute care: n" _tab "Acute care: %" /// _tab "Other: n" _tab "Other: %" _tab "Total: n" _tab "Total: %" foreach var in _sex { local varlab: variable label `var' file write `table' _n "`varlab'" levelsof `var', local(elist) foreach e in `elist' { local xlab: label(`var') `e' ** HIV care visits count if `var'~=. & `var'==`e' & _reasoncat == 2 local n1 = r(N) ** Calculating % local p1: di %3.1f (`n1'/88109)*100 ** Acute care visits count if `var'~=. & `var'==`e' & _reasoncat == 1 local n2 = r(N) ** Calculating % local p2: di %3.1f (`n2'/88109)*100 ** Other visits count if `var'~=. & `var'==`e' & _reasoncat == 4 local n3 = r(N) ** Calculating % local p3: di %3.1f (`n3'/88109)*100 ** Total: across reasons count if `var'~=. & `var'==`e' & (_reasoncat == 1| _reasoncat == 2| _reasoncat == 4) local n=r(N) ** Calculating % local p: di %3.1f (`n'/88109)*100 file write `table' _n "`xlab'" _tab "`n1'" _tab "`p1'" _tab "`n2'" /// _tab "`p2'" _tab "`n3'" _tab "`p3'" _tab "`n'" _tab "`p'" } } ** Total ** HIV care visits count if _reasoncat == 2 local n4 = r(N) ** Calculating % local p4: di %3.1f (`n4'/88109)*100 ** Acute care visits count if _reasoncat == 1 local n5 = r(N) ** Calculating % local p5: di %3.1f (`n5'/88109)*100 ** Other visits count if _reasoncat == 4 local n6 = r(N) ** Calculating % local p6: di %3.1f (`n6'/88109)*100 file write `table' _n "Total" file write `table' _tab "`n4'" _tab "`p4'" _tab "`n5'" _tab "`p5'" /// _tab "`n6'" _tab "`p6'" _tab "88109" _tab "100" }