{smcl} {* 20aug2004}{...} {hline} {center:{hi:Exact binomial CIs}} {hline} {p 4 4 4}{it} A general method for creating complex graphs, or even simple graphs that Stata does not produce with a specific command, is to: {p 8 11 4}1) manage your data using Stata to obtain the points or locations you wish to plot {p 8 11 4}2) plot the points or locations using the appropriate {cmd:twoway} plotttype {c -} {cmd:rbar} for a range plotted with a bar, {cmd:scatter} for a set of points, etc. {sf} {p 0 2 0}o Manage data or results {p 4 4 4}{it} In this example we will use {cmd:statsby} to collect exact binomial confidence intervals for a proportion and plot the results using {cmd:twoway}. (click each command below in sequence.){sf} {p 0 2 0}. {stata sysuse nlsw88 , clear} {stata do statsby0a:. statsby "ci union , binomial"} {stata do statsby0a:"proportion=(r(mean)) lb=(r(lb)) ub=(r(ub)) ,"} {stata do statsby0a:"by(occupation) clear"} {p 0 2 0}. {stata label variable lb ""}{p_end} {p 0 2 0}. {stata label variable ub ""}{p_end} {p 0 2 0}. {stata label variable proportion ""} {p 0 2 0}o Use {cmd:twoway} to plot the results {p 4 4 4}{it} To see variations on graphs of these proportions and sometimes their confidence intervals click the following {cmd:graph} commands. {p 4 5 4}{it} (Note that on Unix-based systems those graphs specifying an angle on the axis labels will not draw the labels correctly in the Graph window; they will, however, produce correct files for export if you use the {cmd:graph export} command.{sf}) . {stata twoway bar proportion occupation} {stata do statsby0b:. twoway bar proportion occupation , barwidth(.75)} {stata do statsby0b:xlabel(1(1)13 , valuelabel angle(45))} {stata do statsby0b:graphregion(margin(l=12))} {stata do statsby0c:. twoway bar proportion occupation , barwidth(.75) ||} {stata do statsby0c:rcap lb ub occupation ,} {stata do statsby0c:xlabel(1(1)13 , valuelabel angle(45))} {stata do statsby0c:graphregion(margin(l=12))} {stata do statsby0d:. twoway bar proportion occupation ,} {stata do statsby0d:horiz barwidth(.75) ||} {stata do statsby0d:rcap lb ub occupation , horiz} {stata do statsby0d:ylabel(1(1)13 , valuelabel angle(0) nogrid)} {stata do statsby0d:ytitle("") xlabel(,grid)} {stata do statsby0d:legend(label(1 "proportion"))} {stata do statsby0e:. twoway scatter occupation proportion ||} {stata do statsby0e:rcap lb ub occupation , horiz} {stata do statsby0e:ylabel(1(1)13 , valuelabel angle(0) nogrid)} {stata do statsby0e:ytitle("") xlabel(,grid)} {stata do statsby0e:legend(label(1 "proportion"))} {hline} {center:{view whytwo.smcl:<<} {view tindex.smcl:index} {view surface.smcl:>>}}