Hello,
I am trying to create a simple twoway bar graph with confidence intervals over two categories. I want to add a label showing sample size (N) on top of each of the bar graphs, but I get an error saying that mlab or blabel not allowed. How can I add just the count of individuals in each group as a label on top of the bar graphs?
I first collapse the data as shown below:
collapse (mean) meanretain_year3= retain_year3 (sd) sdretain_year3=retain_year3 (count) n=retain_year3, by(belongtreat disadvgrp)
Then I generate the CI's:
generate hiretain_year3 = meanretain_year3 + invttail(n-1,0.025)*(sdretain_year3 / sqrt(n))
generate loretain_year3 = meanretain_year3 - invttail(n-1,0.025)*(sdretain_year3 / sqrt(n))
Then I combine the two groups (disadvgrp, belongtreat) into one category - each of those have 2 sub categories
generate disadvgrptreat = belongtreat if disadvgrp == 0
replace disadvgrptreat = belongtreat+5 if disadvgrp == 1
Graph works as expected below:
twoway (bar meanretain_year3 disadvgrptreat if belongtreat==1) ///
(bar meanretain_year3 disadvgrptreat if belongtreat==0) ///
(rcap hiretain_year3 loretain_year3 disadvgrptreat), ///
legend(row(1) order(1 "Intervention" 2 "Control" ) ) ///
xlabel( 0 "Advantaged Students" 5 "Disadvantaged students", noticks) ///
xtitle("Experimental Condition by Demographic Groups") title("Continuous Enrollment Over 2 years post-intervention")
But, both these do not seem to work:
mlabel(tolabel) mlabpos(12) mlabcolor(white) xla(0 1, tlcolor(none) valuelabel)
blabel(total, position(inside) format(%9.1f) color(white))
I have a variable called n in my collapsed dataset that I want to add as a label to the bar graphs on top.
I appreciate any help with my question above. I also apologize if this has been answered before - I could not find responses to a similar question posted on statalist before.
Thank you,
Maithreyi
I am trying to create a simple twoway bar graph with confidence intervals over two categories. I want to add a label showing sample size (N) on top of each of the bar graphs, but I get an error saying that mlab or blabel not allowed. How can I add just the count of individuals in each group as a label on top of the bar graphs?
I first collapse the data as shown below:
collapse (mean) meanretain_year3= retain_year3 (sd) sdretain_year3=retain_year3 (count) n=retain_year3, by(belongtreat disadvgrp)
Then I generate the CI's:
generate hiretain_year3 = meanretain_year3 + invttail(n-1,0.025)*(sdretain_year3 / sqrt(n))
generate loretain_year3 = meanretain_year3 - invttail(n-1,0.025)*(sdretain_year3 / sqrt(n))
Then I combine the two groups (disadvgrp, belongtreat) into one category - each of those have 2 sub categories
generate disadvgrptreat = belongtreat if disadvgrp == 0
replace disadvgrptreat = belongtreat+5 if disadvgrp == 1
Graph works as expected below:
twoway (bar meanretain_year3 disadvgrptreat if belongtreat==1) ///
(bar meanretain_year3 disadvgrptreat if belongtreat==0) ///
(rcap hiretain_year3 loretain_year3 disadvgrptreat), ///
legend(row(1) order(1 "Intervention" 2 "Control" ) ) ///
xlabel( 0 "Advantaged Students" 5 "Disadvantaged students", noticks) ///
xtitle("Experimental Condition by Demographic Groups") title("Continuous Enrollment Over 2 years post-intervention")
But, both these do not seem to work:
mlabel(tolabel) mlabpos(12) mlabcolor(white) xla(0 1, tlcolor(none) valuelabel)
blabel(total, position(inside) format(%9.1f) color(white))
I have a variable called n in my collapsed dataset that I want to add as a label to the bar graphs on top.
I appreciate any help with my question above. I also apologize if this has been answered before - I could not find responses to a similar question posted on statalist before.
Thank you,
Maithreyi
Comment