Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 73242

Creating bar chart with multiple binary variables

$
0
0
Hi, I am attempting to create a bar chart in Stata that shows proportions for multiple different binary variables. Each is a different measure of whether or not a medical provider offered a certain service at a health visit (yes/no). I've tried to recreate a reproducible example here that is similar to my dataset, along with the code I have tried so far to create this. Wondering if there's any way that I can show bar for both yes and no for each indicator? Also I am trying to relabel the variable names on the y axis but this code yields an invalid 'ylabel' error. New Stata user and first attempt at posting a reproducible example, please let me know if this isn't clear!

Code:
set obs 10
egen id = seq(), from(1) to(10)
gen fp = cond(mod(_n, 2), 0, 1)
gen cervical = cond(mod(_n, 4), 0, 1)
gen immunization = cond(mod(_n, 6), 0, 1)
lab define fp 0 "No" 1 "Yes"
lab define cervical 0 "No" 1 "Yes"
lab define immunization 0 "No" 1 "Yes"
lab values fp fp 
lab values cervical cervical
lab values immunization immunization

statplot fp cervical immunization, varopts(sort(1)) blabel(bar), ylabel(fp "Provider discussed family planning with mother" cervical "Provider offered cervical cancer screening to mother" immunization "Provider immunized baby")

Viewing all articles
Browse latest Browse all 73242

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>