Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Adding Reference Bars to Bar Graph


From   William Buchanan <[email protected]>
To   [email protected]
Subject   st: Adding Reference Bars to Bar Graph
Date   Thu, 16 Aug 2012 21:33:59 -0700

Hi Everyone,

I'm trying to automate production of a series of bar graphs that show the percentage of values and am having difficulty adding an extra bar with a constant value to the graph.  With the exception of this additional bar, I've managed to get something close to the current graphs being used with -catplot- (available from SSC; written by Nick Cox).  The syntax that I've used so far (with only slight modification) is:

catplot schoolyr, over(skills) asyvar recast(bar) blabel(total, format(%2.0f)) percent(schoolyr) bar(1,color(green*.85) lc(black) lw(medthin)) bar(2, color(blue*.325) lc(black) lw(medthin)) ysc(r(0(10)100) lc(black)) ylab(0(10)100, angle(0) glc(black) tlw(vvthin) glw(vvthin)) yti(Percent) legend(label(1 "XXXXX Yr 2 (N=84)") label(2 "XXXXX Yr 3 (N=116)") pos(12) span region(lc(white))) ti("Survey Item Here", color(black)) b1title(" ") graphr(fc(white) color(white) ic(white)) 


My goal is to get an additional bar added to the graph with  values showing the percentage of "overall".  In the actual dataset, the "overall" measure is a time-invariant constant and the firm wants to keep the same graphics formatting that they have already used.  I've tried messing around with the -over()- options and by adding the additional variable to the -varlist- in the command.  In each of these cases, there is a change to the x-axis (instead of showing an additional bar, the bars are disaggregated by the additional variable). I've provided syntax to generate something close to the data that I am working with.  The only difference between the syntax above and what I will eventually need to work with is the addition of an -if- statement that will be used to loop over the firms in the dataset. 

Thanks in advance for any assistance,
Billy


set obs 200
set seed 10101
g schoolyr=2 if _n<=84
replace schoolyr=3 if schoolyr==.
g sk=runiform()
egen skills=cut(sk), group(4)
sort skills
g overall=1 if _n<=25
replace overall=2 if _n<=50 & _n>=26
replace overall=3 if _n<=75 & _n>=51
replace overall=3 if _n>=76
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index