Announcement

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

  • Graph displaying fractions correctly but not the percentages

    So I figured out how to obtain a 4-year graduation rate by creating a new variable. I created the variable in the following way

    Code:
    gen grad4=1 if Graduation==1 & (Duration==3 | Duration==4)
    (9643 missing values generated)
    
    replace grad4=0 if grad4==.
    (9643 real changes made)
    I then use a bar graph to represent the data (for years 2012 and 2013, one cannot not have graduated within 3 years and for 2011, one cannnot have graduated within 4 years but I will deal with that later). This graph is correct, and displaying fractions correctly.

    I used the following code:

    Code:
    graph bar grad4, over(Year) asyvars blabel(bar, format(%9.2f))



    However, I'd like it in percentages, but when I run the following code:

    Code:
    graph bar grad4, over(Year) asyvars blabel(bar, format(%9.2f)) percent
    it displays the following:




    Why would this be the case? Why would simply adding the "percent" change my results so dramatically?
    Attached Files

  • #2
    The proportions don't add up to one, while the percentages add up to 100%. I suspect that that is the reason, the percent option takes values without looking at what they mean (how could it?) and computes percentages.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Originally posted by Maarten Buis View Post
      The proportions don't add up to one, while the percentages add up to 100%. I suspect that that is the reason, the percent option takes values without looking at what they mean (how could it?) and computes percentages.
      Ah yes, I see. You're right - I looked at the graduation rate per year. Would you know any possible solution?

      Comment


      • #4
        Figured it out - don't worry. Thanks to this article - http://www.stata.com/support/faqs/da...ary-variables/

        Comment


        • #5
          Note also catplot (SSC), as suggested to you in the previous thread.

          Comment


          • #6
            Here is another way to do it, avoiding the multi-coloured mess that makes some sense for categorical variables, but not so much for your kind of problem.

            Code:
             
            clear 
            input rate year 
            51  2006
            49  2007
            46  2008
            41  2009
            53  2010 
            13  2011
            end 
            twoway bar rate year, xla(2006/2011, noticks) base(0) barw(0.9) ytitle(% graduating) xtitle("") ///
            || scatter rate year, ms(none) mla(rate) mlabpos(12) mlabcolor(black) mlabsize(*1.2)  ///
            ysc(r(0 55)) yla(, ang(h)) legend(off)


            I would hope that you and your audience would regard this as a simpler, clearer design. We lost the legend (slogans: kill the key! lose the legend!) and simplified other stuff too.

            Naturally, you don't have to enter the summaries as a new data set. You just cited an FAQ that explains how to get percent summary variables in your dataset.

            Also, in your data the percents will have some arbitrary number of decimal places.

            In that case don't use something like

            mla(rate)

            above, but something like

            Code:
            gen srate = string(rate, "%2.1f")
            and then feed that variable to mla(). To round to 0, 1, 2, 3, etc. decimal places, use formats %1.0f, %2.1f, %3.2f, %4.3f, etc. Here 1 decimal place is probably more than anyone really needs.



            Attached Files

            Comment

            Working...
            X