Announcement

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

  • Stata graphs

    Hello

    I am trying to graph a histogram or a bar chard by using the if and by commands but I have some problems . I have an EBITDA Variable for several firms and a YR Variable for the Year 2004-2014 but only want to display the YR 2006-2010. But both comands result in an error.

    Code:
    graph hbar (mean) EBITDA if YR== 2006,2007,2008,2009,2010, over(IND) over(YR)
    graph hbar (mean) EBITDA if YR==2006-2010, over(IND) over(YR)

    The samen Problem I have if I like to graph a bar with MLEV which is the median leverage over IND (Industry) by Year. Where IND is the original Variable were all Industries are in. IND1-9 are Industry dummies. I like to have a graph wehre I can see the median Leverage over industries and over years.

    Code:
    graph bar (asis) MLEV, over(IND1, IND2, IND3, IND4, IND5, IND6, IND7, IND8, IND9) over(YR)
    invalid 'IND3'
    r(198);

    graph hbar (asis) EBITDA, over(YR)
    variables YR _variables do not uniquely identify the observations
    r(459);

    Many Thanks for your help.
    I couldn't give you a dataex as my set is too long and a shorter range need a by command where I have my problems. Sorry





  • #2
    - if YR== 2006,2007,2008,2009,2010- is not legal Stata syntax. Neither is -if YR==2006-2010-. What I think you are trying to accomplish would be correctly expressed as -if inlist(YR, 2006, 2007, 2008, 2009, 2010)-, or -if inrange(YR, 2006, 2010)-.

    If you check the help for -graph bar- you will see that the -over()- option does not allow specification of multiple variables, only one.

    The final error you are facing, that YR _variables do not uniquely identify the observations means exactly what it says. You have multiple observations in your data for the same YR, so there is no way to create the graph you have asked for: how is Stata to know which of the many observations for a given value of YR is to be used in the graph. If you want something like a graph of the average value of EBITDA for each YR, then replace -(asis)- by -(mean)- in your command, and you will get it.

    Comment


    • #3
      Many thanks for our help. I have now understant the error

      Comment

      Working...
      X