I'd like to display the labels for the bar graph below as percents (with a "%" sign after them), but don't know how to do this beyond manually adding them using blabel().
I am looking for a solution that's automated. Please correct me if this is wrong, but I don't think that there is a way to format variables to include percents that would then show up in a graph (as there is for commas).
sysuse auto, clear
generate p_over_5k = 0
replace p_over_5k = 1 if price > 5000
generate mileage = "Low" if mpg < 20
replace mileage = "High" if mpg >= 20
generate ones = 1
collapse (sum) ones p_over_5k, by(foreign mileage)
generate pr_over_5k = round(p_over_5k/ones, 0.01)*100
graph bar (asis) pr_over_5k, over(foreign) over(mileage) asyvars blabel(bar) ytitle("Percent of Cars Over $5,000")
Thank you for any assistance you can provide,
Erika
I am looking for a solution that's automated. Please correct me if this is wrong, but I don't think that there is a way to format variables to include percents that would then show up in a graph (as there is for commas).
sysuse auto, clear
generate p_over_5k = 0
replace p_over_5k = 1 if price > 5000
generate mileage = "Low" if mpg < 20
replace mileage = "High" if mpg >= 20
generate ones = 1
collapse (sum) ones p_over_5k, by(foreign mileage)
generate pr_over_5k = round(p_over_5k/ones, 0.01)*100
graph bar (asis) pr_over_5k, over(foreign) over(mileage) asyvars blabel(bar) ytitle("Percent of Cars Over $5,000")
Thank you for any assistance you can provide,
Erika
Comment