Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Concerning how to make a bar graph: top 3 observations being each bar?

    Good Day Fellow Stata-ers!

    This is my first post, and I am still fairly new to Stata; please excuse me if this seems like a simple question! I am dealing with a department of education dataset, and am making a bar graph that calculates the max of the number of absences (y axis) with regard to school year [there are 3: 2010-2011, 2011-2012, and 2012-2013 ( this is the x axis)]. The thing is, the bar graph just spews out the highest observation for y axis with regard to the x axis!I am curious to see if there is a way to get the top 3 highest observations with regard to the number of absences included on my graph instead of just the no 1 highest observation? The variable that I want to have be the top 3 highest observations is school district code, and I will just make a legend stating which district it is. Does this make any sense? I have been racking my brain just trying to figure this out.

    Pretty much the syntax I am using is
    graph bar (max) Absent21Days, over(year)

    Is there any way I can include the top 3 districts ("DistCode") as a separate bar? (e.g., if 1,5, and 13 were the districts with the highest amount of absences...could I make them separate bars, or would this be now more suited for a histogram)?

    Thanks so much for your help! Any reply is most welcome

    Jonathan Centeno

  • #2
    Here's some technique:

    Code:
     
    sysuse auto
    bysort foreign (mpg) : gen highest =  inlist(_n, _N, _N-1, _N-2)
    graph hbar (asis) mpg if highest , over(make) over(foreign) nofill
    You should select the three highest outside graph bar and then plot them "as is". This code would need tweaking if there are missing values.



    Comment

    Working...
    X