Announcement

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

  • Stacked Bar Graph

    Hello,

    I am fairly new to Stata and am having some trouble. I am trying to create a stacked bar graph with expenditure on my y-axis and age on my x-axis. I want to stack the percentage of spending on Medicaid and Medicare. I have tried different combinations of code but am having some trouble. Any help is greatly appreciated.

    Code:

    graph bar (mean) TotalEXP [pweight = weight], over (Age) over (Evermedicaid) over (Evermedicare) stack percentages blabel(bar) title(Figure 1: Average Health Expenditures by Age)


  • #2
    assuming medicaid and medicare are mutually exclusive,
    Code:
    collapse TotalEXP ,by(Age Evermedicaid)
    reshape wide TotalEXP ,i(Age) j(Evermedicaid)
    graph hbar TotalEXP* ,over(Age) stack percent

    Comment


    • #3
      Øyvind Snilsberg, thank you for this.

      Comment

      Working...
      X