Tuesday, June 7, 2022

Create bar charts with data in multiple columns

Hello! I'm using ODK to collect data in the field, for example symptoms experienced by cases, as checkboxes (multiple responses per case). The output is a data table with one column for each symptom. I would like to quickly create a horizontal bar chart to show the frequency of symptoms. What I currently do is to create a separate data table (using Excel's pivot table) which summarizes the frequency of each symptom, then create a chart from there. But I was wondering if it was possible to do it in Stata without going through the intermediate step of creating a summary table for the frequency of symptoms? Attached is an example of my dataset.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str4 interviewer_code byte(all_symptomsfever all_symptomsheadache all_symptomsmalaise all_symptomsmyalgia all_symptomsarthralgia)
"AB"   1 0 1 1 1
"AB"   1 0 0 0 0
"JR"   1 0 0 0 0
"MGH"  1 0 1 0 0
"JS"   1 1 0 0 0
"JS"   1 0 0 0 0
"Resu" 1 1 1 0 0
"Resu" 1 0 0 0 0
"Resu" . . . . .
"EBR"  1 1 0 0 0
end

No comments:

Post a Comment